问题
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.
Unfortunately, what happens is that the AppleMessageListener writes the message to "outQueue". The AppleMessageListener times out waiting for a response. Only after this timeout does the PearMessageListener read the message from the "outQueue". It is as if whilst the AppleMessageListener is waiting for a response, the PearMessageListener is prevented from reading the message.
Any thoughts on why this is the case please. Thank you for your help.
Pete
来源:https://stackoverflow.com/questions/50544584/sping-jms-listener-blocking-another-listener-from-reading-jms-message