First of all, I am a newbie in terms of Spring Integration and Spring JMS, so maybe the solution I try to adopt is not the correct one for my requirements.
I will try to explain what I am required to implement: basically, I need to place a message in a queue and asynchronously wait for an answer in another queue.
1. Place a message in a queue:
My solution:
<int-jms:outbound-gateway id="sendMessageOutboundGW"
connection-factory="jmsGatewayConnectionFactory"
request-channel="marshaledSendMessageJmsRequestChannel"
request-destination="sendMessageRequestQueue"
requires-reply="false"
reply-destination="sendMessageResponseQueue"
correlation-key="JMSCorrelationID">
</int-jms:outbound-gateway>
--> this works fine, I can see the messages being placed in the queue
2. Asynchronously listen for a reply message from another queue:
My solution 1:
<bean id="messageListenerContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
<property name="connectionFactory" ref="jmsGatewayConnectionFactory" />
<property name="destination" ref="sendMessageResponseQueue" />
<property name="messageListener" ref="messageListener" />
<property name="errorHandler" ref="sendMessageResponseErrorHandler" />
</bean>
<int-jms:message-driven-channel-adapter id="sendMessageInboundGW"
container="messageListenerContainer"
channel="sendMessageJmsResponseChannel" />
The custom MessageListener implements javax.jms.MessageListener.
However, it looks that the message listener I set for the messageListenerContainer is being overridden and a org.springframework.integration.jms.ChannelPublishingJmsMessageListener is being used instead. I can see in the logs that the messages received are being picked up by the messageListenerContainer.
Also, with this solution I can see in the logs the following WARN message The provided listener container already has a MessageListener implementation, but it will be overridden by the provided ChannelPublishingJmsMessageListener.
My solution 2:
<bean id="messageListenerContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
<property name="connectionFactory" ref="jmsGatewayConnectionFactory" />
<property name="destination" ref="sendMessageResponseQueue" />
<property name="messageListener" ref="messageListener" />
<property name="errorHandler" ref="sendMessageResponseErrorHandler" />
</bean>
<int-jms:inbound-gateway id="sendMessageInboundGW"
container="messageListenerContainer"
request-channel="sendMessageJmsResponseChannel"
request-destination="sendMessageResponseQueue"
correlation-key="JMSCorrelationID" />
I have the same issue with this solution -- the custom MessageListener is being overridden.
Not using the custom MessageListener, I get the following error:
org.springframework.messaging.core.DestinationResolutionException: no output-channel or replyChannel header available
What am I doing wrong?
Any help would be much appreciated.