简体   繁体   中英

Mule ESB simple jdbc insert

I'm trying to force Mule ESB Studio, to perform some simple insert into a 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.

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. 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.

Second question is, how to inject to DB value I've specified in 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.

Thanks in advance.

I'm guessing uncommitted transaction here. Try adding transactionPerMessage="true" to your <jdbc-ee:connector...

I noticed similar issue in Mule-EE, Mule-CE works fine...

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". Changing payload to other type of an Object for this jdbc call solved the issue. To keep an open mind, consider: -passing SQL query parameters via a Payload instead -consider message enrichers

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM