I have two applications Apple and Pear that uses the above class to listen on a configured JMS queue in WildFly ( 10.1.0 ). The Spring configuration is shown below.
<bean id="appleMessageListenerContainer"
class="org.springframework.jms.listener.DefaultMessageListenerContainer"
depends-on="transactionManager">
<property name="connectionFactory" ref="connectionFactory" />
<property name="destination" ref="outQueue" />
<property name="destinationResolver" ref="jmsDestinationResolver" />
<property name="messageListener" ref="AppleMessageListener" />
<property name="messageSelector" value="ID='APPLE_ID'" />
<property name="transactionManager" ref="transactionManager" />
</bean>
<bean id="pearMessageListenerContainer"
class="org.springframework.jms.listener.DefaultMessageListenerContainer"
depends-on="transactionManager">
<property name="connectionFactory" ref="connectionFactory" />
<property name="destination" ref="outQueue" />
<property name="destinationResolver" ref="jmsDestinationResolver" />
<property name="messageListener" ref="PearMessageListener" />
<property name="messageSelector" value="ID='PEAR_ID'" />
<property name="transactionManager" ref="transactionManager" />
</bean>
The expected process is as follows :- Apple application listener ( AppleMessageListener ) will read a message from a "outQueue" JMS queue. The message is updated and the AppleMessageListener will write the message out to the "outQueue" with the senderId set to "PEAR_ID", so that the PearMessageListener will read the message. The AppleMessageListener will wait for a response from Pear application on different "inQueue" or timeout
Extarct from the following link :-
https://www.ibm.com/support/knowledgecenter/en/SSFKSJ_7.5.0/com.ibm.mq.dev.doc/q032250_.htm
If an application sends a message within a transaction, the message
is not delivered to its destination until the transaction is committed.
This means that an application cannot send a message and receive a reply
to the message within the same transaction.
This is exactly my situation. However, I am not able to find a solution to this that I can understand.
I would very much appreciate for suggestions to over come this issue I am facing.
Thank you for your help.
Pete