Is there a requirement for jms messages to be sent at the end of the commit?

I have a strange phenomenon that jms messages seem to be sent before the data collection actually happened.

Suppose I have a server operation foo () that sends a message to the client when it is complete. The client then downloads the changed data from the server. Now it seems that the jms message was sent before the commit was actually completed, so the client is still receiving the old data, because its request is still up to the end of the initial commit.

The whole server operation is definitely transactional, because if an exception is thrown, the jms event is not dispatched.

Is there any requirement in the jms specification that needs to happen first for all database transactions and then send a jms message, or does it depend on the implementation, in what order does this happen?

We are talking about the default implementation of hornetq in jboss 6.0.0.Final.

Update:

It seems I have the same problem as these guys: http://techstack.com/forum/websphere/34434-order-commits-xa-transaction.html

Update 2:

Another user with the same problem http://community.jboss.org/message/114459

+4
source share
2 answers

JMS operations are transactional, so the jms message is delivered during commit. If you want to see the committed data, add db operations to another EJB method with the REQUIRES_NEW transaction property.

0
source

You just need to make sure your Factory connection is part of the same XA transaction.

you need to set REQUIRES_NEW to the EJB, as Gursel Coca said in another post.

It will be easier to use the JCA Connection Factory (usually in java: // JmsXA)

0
source

All Articles