Reputation: 14393
How to create dynamic jms outbound-gateway using spring-integration ? My application has the following architecture,
request -> appA -> activemq -> appB -> activemq -> appA -> response
I would like to create a service that can send messages to multiple activemq instances. I have gone through the dynamic ftp sample described @ https://github.com/spring-projects/spring-integration-samples/tree/master/advanced/dynamic-ftp. But i would like to understand how to create dynamic outbound-gateway.
<bean id="jmsSecureConnectionFactory" class="org.apache.activemq.spring.ActiveMQConnectionFactory">
<property name="brokerURL" value="${brokerUrl}" />
</bean>
<bean id="jmsPooledConnectionFactory" class="org.apache.activemq.jms.pool.PooledConnectionFactory">
<property name="connectionFactory" ref="jmsSecureConnectionFactory" />
<property name="createConnectionOnStartup" value="false" />
<property name="maxConnections" value="1" />
<property name="maximumActiveSessionPerConnection" value="1" />
<property name="idleTimeout" value="10" />
</bean>
<int:channel id="clientGatewayChannel" />
<int:gateway id="jmsMessageServiceGateway"
service-interface="com.abc.JmsMessageServiceGateway"
default-request-channel="clientGatewayChannel" />
<int-jms:outbound-gateway request-channel="clientGatewayChannel"
request-destination-expression="'REQUEST.' + payload.processor"
reply-destination-expression="'RESPONSE.' + payload.processor"
extract-request-payload="true" connection-factory="jmsPooledConnectionFactory" />
<bean id="jmsChannelResolver" class="com.abc.JmsChannelResolver" />
<int:channel id="dynamicRouter" />
<int:router input-channel="dynamicRouter"
expression="@jmsChannelResolver.resolve(payload.processor)" />
I can see the request message getting enqueued and dequeued and the response message getting enqueued and dequeued. But then i get an exception,
org.springframework.integration.support.channel.ChannelResolutionException: no output-channel or replyChannel header available
How should i retrieve the response ?
Upvotes: 0
Views: 1515
Reputation: 174564
That error means that whatever you are sending to dynamicRouter
did not originate from a component that set up a replyChannel
header (examples that do include gateway, inbound gateways and MessagingTemplate.sendAndReceive()
methods).
Or, something has removed that header before the message arrived at dynamicRouter
.
What you have should work fine as long as the upstream flow is correct.
You need to show the rest of your application.
Upvotes: 1