[英]Mule ESB simple jdbc insert
I'm trying to force Mule ESB Studio, to perform some simple insert into a jdbc. 我试图强迫Mule ESB Studio在jdbc中执行一些简单的插入操作。 My goal is to open a page in my webbrowser, let's say it's
http://localhost:8081/
, and then Mule ESB performs insert 'foobar' value into database. 我的目标是在Web浏览器中打开一个页面,假设它是
http://localhost:8081/
,然后Mule ESB执行将“ foobar”值插入数据库。
Here's my code: 这是我的代码:
<jdbc-ee:mssql-data-source name="MS_SQL_Data_Source" user="esbtest" password="Test123" transactionIsolation="NONE" doc:name="MS SQL Data Source" loginTimeout="10000"
url="jdbc:sqlserver://10.1.212.42:1433;databaseName=test"></jdbc-ee:mssql-data-source>
<jdbc-ee:connector name="Database" dataSource-ref="MS_SQL_Data_Source" validateConnections="true" queryTimeout="-1" pollingFrequency="0" doc:name="Database"/>
<flow name="Test_PierwszyFlow1" doc:name="Test_PierwszyFlow1">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" doc:name="HTTP" mimeType="text/plain"></http:inbound-endpoint>
<object-to-string-transformer doc:name="Object to String"/>
<jdbc-ee:outbound-endpoint exchange-pattern="one-way" queryTimeout="-1" doc:name="Database" connector-ref="Database" queryKey="insertQuery">
<jdbc-ee:query key="insertQuery" value="INSERT INTO t_Login (login) VALUES ('foo bar')"/>
</jdbc-ee:outbound-endpoint>
</flow>
I've not specified any beans or such things. 我没有指定任何豆子或类似的东西。 In logs, I see these lines:
在日志中,我看到以下几行:
INFO 2013-07-02 11:20:37,550 [[test_pierwszy].connector.http.mule.default.receiver.02] org.mule.lifecycle.AbstractLifecycleManager: Initialising: 'Database.dispatcher.1938839184'. Object is: EEJdbcMessageDispatcher
INFO 2013-07-02 11:20:37,550 [[test_pierwszy].connector.http.mule.default.receiver.02] org.mule.lifecycle.AbstractLifecycleManager: Starting: 'Database.dispatcher.1938839184'. Object is: EEJdbcMessageDispatcher
INFO 2013-07-02 11:20:37,670 [[test_pierwszy].connector.http.mule.default.receiver.02] com.mulesoft.mule.transport.jdbc.sqlstrategy.UpdateSqlStatementStrategy: Executing SQL statement: 1 row(s) updated
INFO 2013-07-02 11:20:37,730 [[test_pierwszy].connector.http.mule.default.receiver.02] com.mulesoft.mule.transport.jdbc.sqlstrategy.UpdateSqlStatementStrategy: Executing SQL statement: 1 row(s) updated
...but my database is empty! ...但是我的数据库是空的! I must say, I am totally new in Mule ESB area and have no idea what is wrong.
我必须说,我是Mule ESB领域的新手,不知道哪里出了问题。 Please - help.
请帮忙。
Edit: Funny thing is, that when I change talbe or column name to something, that does not exist, I get JDBC error corresponding to that matter. 编辑:有趣的是,当我将talbe或列名更改为某种不存在的内容时,我得到了与该问题相对应的JDBC错误。
Second question is, how to inject to DB value I've specified in URL? 第二个问题是,如何注入我在URL中指定的数据库值? For example, when I type in browser
http://localhost:8081/foo
, the value foo is passed to jdbc outcome connector, and 'foo' value is inserted. 例如,当我在浏览器中输入
http://localhost:8081/foo
, http://localhost:8081/foo
值foo传递到jdbc结果连接器,并插入'foo'值。
Thanks in advance. 提前致谢。
I'm guessing uncommitted transaction here. 我猜这里未提交的交易。 Try adding
transactionPerMessage="true"
to your <jdbc-ee:connector...
尝试将
transactionPerMessage="true"
添加到您的<jdbc-ee:connector...
I noticed similar issue in Mule-EE, Mule-CE works fine... 我在Mule-EE中发现了类似的问题,Mule-CE正常工作...
When you call jdbc:outbound-endpoint with an ArrayList payload but use SESSION/INVOCATION variables as params in your SQL query, I noticed it has no effect on the table in question (no Insert/Update) yet logger records "Record Updated". 当您使用ArrayList有效负载调用jdbc:outbound-endpoint,但在SQL查询中使用SESSION / INVOCATION变量作为参数时,我注意到它对所讨论的表没有影响(无插入/更新),但记录器记录“记录已更新”。 Changing payload to other type of an Object for this jdbc call solved the issue.
将此jdbc调用的有效负载更改为其他类型的Object即可解决此问题。 To keep an open mind, consider: -passing SQL query parameters via a Payload instead -consider message enrichers
要保持开放的态度,请考虑:-通过有效负载传递SQL查询参数-考虑消息浓缩器
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.