title: Dynamic jms outbound-gateway
body: <p>How to create dynamic jms outbound-gateway using spring-integration ? My application has the following architecture,</p>
  
  <pre><code>request -&gt; appA -&gt; activemq -&gt; appB -&gt; activemq -&gt; appA -&gt; response
  </code></pre>
  
  <p>I would like to create a service that can send messages to multiple activemq instances. I have gone through the dynamic ftp sample described @ <a href="https://github.com/spring-projects/spring-integration-samples/tree/master/advanced/dynamic-ftp" rel="nofollow">https://github.com/spring-projects/spring-integration-samples/tree/master/advanced/dynamic-ftp</a>. But i would like to understand how to create dynamic outbound-gateway.</p>
  
  <pre><code>&lt;bean id="jmsSecureConnectionFactory" class="org.apache.activemq.spring.ActiveMQConnectionFactory"&gt;
      &lt;property name="brokerURL" value="${brokerUrl}" /&gt;
  &lt;/bean&gt;
  
  &lt;bean id="jmsPooledConnectionFactory" class="org.apache.activemq.jms.pool.PooledConnectionFactory"&gt;
      &lt;property name="connectionFactory" ref="jmsSecureConnectionFactory" /&gt;
      &lt;property name="createConnectionOnStartup" value="false" /&gt;
      &lt;property name="maxConnections" value="1" /&gt;
      &lt;property name="maximumActiveSessionPerConnection" value="1" /&gt;
      &lt;property name="idleTimeout" value="10" /&gt;
  &lt;/bean&gt;
  
  &lt;int:channel id="clientGatewayChannel" /&gt;
  
  &lt;int:gateway id="jmsMessageServiceGateway"
      service-interface="com.abc.JmsMessageServiceGateway"
      default-request-channel="clientGatewayChannel" /&gt;
  
  &lt;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" /&gt;
  
  &lt;bean id="jmsChannelResolver" class="com.abc.JmsChannelResolver" /&gt;
  
  &lt;int:channel id="dynamicRouter" /&gt;
  
  &lt;int:router input-channel="dynamicRouter"
      expression="@jmsChannelResolver.resolve(payload.processor)" /&gt;
  </code></pre>
  
  <p></p>
  
  <p>I can see the request message getting enqueued and dequeued and the response message getting enqueued and dequeued. But then i get an exception,</p>
  
  <pre><code>org.springframework.integration.support.channel.ChannelResolutionException: no output-channel or replyChannel header available
  </code></pre>
  
  <p>How should i retrieve the response ?</p>