[jboss-dev-forums] [Design of JBoss ESB] - ServiceInvoker / deliver in new transaction
camunda
do-not-reply at jboss.com
Fri Nov 28 07:48:08 EST 2008
Hi.
I have an issue with the ServiceInvoker: When you want to use deliverSync in a transactional context (let's say in a EJB3-SLSB) and you use JMS as provider, this will not work correctly.
Since the JMS message will be delivered in the transaction of the SLSB the ESB cannot start work before the transaction commits. But in deliverSync we wait for an answer (which cannot come).
If I need a deliverSync within transactional context, my only possibility is to use deliverAsync in an own transaction and then wait for an answer, like this:
| try {
| // if we get an exception in the next method this transaction is rolled back as well
| callDeliverSyncInOwnTransaction();
| // now the ServiceInvoker succeeded, so the service is called correctly
| Message m = waitForAnswer();
| // do something with answer
| }
| catch (TimeoutException ex) {
| // OK, now we need some clever code to handle this situation!
| // message sent but the answer timed out and will come sometime in future
| }
|
This behavior isn't really supported by the ServiceInvoker out of the box, or did I miss something? I would need to implement that callDeliverSyncInOwnTransaction myself (maybe I could use a SLSB method with @RequiresNew, or without using EJB I could suspend the transaction, create a new one, send and commit and resume the old one via the TransactionManager directly) and the waitForAnswer.
Would be cool if the ESB supports this pattern out of the box, or what do you think?
Since the deliverSync is quite powerfull, but more or less useless in JTA/JMS environment.
Cheers
Bernd
P.S: Sorry if this is the wrong forum, wasn't sure about using User or Developer Forum, please move it accordingly if you think it is wrong...
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4193008#4193008
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4193008
More information about the jboss-dev-forums
mailing list