title: spring integration with activemq
body: <p>I'm utilizing spring for about a year and everything was pretty obvious and simple until I faced spring integration. Ashamed, I can't create Outbound Gateway to send message to remote JMS (ActiveMQ) channel. Before integration I just used JmsTemplates and @JmsListeners directly, there were no problems at all.</p>
  
  <ol>
  <li>What's the difference between <code>request-destination</code> and <code>request-channel</code>?</li>
  <li><p>Here are my configs: </p>
  
  <pre><code>    @Configuration
      @EnableJms
      public class JmsConfig {
       ...
  
  
          @Value("${activemq.url}")
          private String brokerUrl;
  
  
          @Bean
          public JmsTemplate jmsTemplate() {
              JmsTemplate jmsTemplate = new JmsTemplate(queueConnectionFactory());
              jmsTemplate.setDefaultDestinationName(bookingChannelName);
              return jmsTemplate;
          }
          /*
          @Bean(name = "bookingChannel")
          public Queue activeMQQueue() {
              return new ActiveMQQueue(bookingChannelName);
          }
          */            
  
  
          @Bean
          public JmsListenerContainerFactory jmsListenerContainerFactory() {
              SimpleJmsListenerContainerFactory listenerFactory = new SimpleJmsListenerContainerFactory();
              listenerFactory.setConnectionFactory(queueConnectionFactory());
              return listenerFactory;
          }
          ...
  </code></pre>
  
  <p>}</p>
  
  <p>and an xml one, where all I've got in root <code>beans</code> element is:</p>
  
  <pre><code>&lt;jms:outbound-gateway request-destination-name="reqDestination" request-channel="bookingChannel" /&gt;
  </code></pre>
  
  <p>Then, there is a gateway code:</p>
  
  <pre><code>@MessagingGateway
  public interface BookingGateway&lt;T&gt; {
  
      @Gateway
      void bookTicket(T ticket);
  }
  </code></pre>
  
  <p>And finally, here is how I use a gateway:</p>
  
  <pre><code>@Component
  public class BookingGatewayImpl&lt;T&gt; {
  
  
      @Autowired
      private BookingGateway bookingGateway;
  
      public &lt;U&gt; void bookTicket(T ticket, BiConsumer&lt;T, U&gt; onStatusReceived) {
          bookingGateway.bookTicket(ticket); // second param is not utilized yet
      }
  }
  </code></pre></li>
  </ol>
  
  <p>And when ticket is about to be booked, I get: </p>
  
  <pre><code>send is not supported, because no request channel has been configured
  </code></pre>
  
  <p>Also, I am not able to uncomment ActiveMQQueue bean from the first listing because spring says it is not compatible with MessageChannel:</p>
  
  <pre><code>Bean named 'bookingChannel' must be of type [org.springframework.messaging.MessageChannel], but was actually of type [org.apache.activemq.command.ActiveMQQueue]
  </code></pre>
  
  <p>Why oh why should the destination be of <code>MessageChannel</code> type? What exactly am I doing wrong and how to get this ticket message to be sent?</p>