[英]Mule ESB simple jdbc insert
我試圖強迫Mule ESB Studio在jdbc中執行一些簡單的插入操作。 我的目標是在Web瀏覽器中打開一個頁面,假設它是http://localhost:8081/
,然后Mule ESB執行將“ foobar”值插入數據庫。
這是我的代碼:
<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>
我沒有指定任何豆子或類似的東西。 在日志中,我看到以下幾行:
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
...但是我的數據庫是空的! 我必須說,我是Mule ESB領域的新手,不知道哪里出了問題。 請幫忙。
編輯:有趣的是,當我將talbe或列名更改為某種不存在的內容時,我得到了與該問題相對應的JDBC錯誤。
第二個問題是,如何注入我在URL中指定的數據庫值? 例如,當我在瀏覽器中輸入http://localhost:8081/foo
, http://localhost:8081/foo
值foo傳遞到jdbc結果連接器,並插入'foo'值。
提前致謝。
我猜這里未提交的交易。 嘗試將transactionPerMessage="true"
添加到您的<jdbc-ee:connector...
我在Mule-EE中發現了類似的問題,Mule-CE正常工作...
當您使用ArrayList有效負載調用jdbc:outbound-endpoint,但在SQL查詢中使用SESSION / INVOCATION變量作為參數時,我注意到它對所討論的表沒有影響(無插入/更新),但記錄器記錄“記錄已更新”。 將此jdbc調用的有效負載更改為其他類型的Object即可解決此問題。 要保持開放的態度,請考慮:-通過有效負載傳遞SQL查詢參數-考慮消息濃縮器
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.