I have two inserts that I want to have under transactional control. If one of them does not work, the other should not be executed / inserted. This works great when doing it right in MySQL, like this
START TRANSACTION; INSERT INTO table (field) VALUES (value); INSERT INTO table2 (field) VALUES (value); COMMIT;
Now, using a camel, I already tried
<to uri="sql:START TRANSACTION; INSERT INTO table (field) VALUES (value);INSERT INTO table2 (field) VALUES (value);COMMIT;"/>
which creates sql syntax error. The second thing I tried is
<to uri="sql:START TRANSACTION"/> <to uri="sql:INSERT INTO table (field) VALUES (value)"/> <to uri="sql:INSERT INTO table2 (field) VALUES (value)"/> <to uri="sql:COMMIT"/>
which works, but if one insert fails, the other is still running and pasted.
I also found this http://camel.apache.org/transactional-client.html , but I use a plan, and these examples only look for spring. So if someone got a good example of doing this with a camel plan, that would be great.
Can someone help me do this on a camel?
java mysql apache-camel transactions
Milla
source share