title: Spring Integration Load Balance to JMS Queues
body: <p>I would like to take JMS msgs from a single input queue and fan them out onto N output queues.</p>
  
  <p>I have a simple flow that will forward messages to a single destination but can not figure out how to apply LoadBalancer to allow for multiple destinations in round-robin fashion.</p>
  
  <p>Any ideas how to do this?</p>
  
  <pre><code>@Configuration
  public class TestLoadBalance {
  
      public static final String INPUT_QUEUE = "_dev.lb.input";
      public static final String OUTPUT_QUEUE_PREFIX = "_dev.lb.output-";
  
  
      @Bean
      public IntegrationFlow testLoadBalanceFlow(
              ConnectionFactory jmsConnectionFactory) {
  
          IntegrationFlow flow =  IntegrationFlows.from(
                  Jms.messageDrivenChannelAdapter(jmsConnectionFactory)
                          .destination(INPUT_QUEUE)
          )
                  .handle(buildOutput(jmsConnectionFactory, 1))
                  // cant have 2nd handle. gets warn &amp; flow end:
                  // The 'currentComponent' (org.springframework.integration.jms.JmsSendingMessageHandler@516462cc) 
                  // is a one-way 'MessageHandler' and it isn't appropriate to configure 'outputChannel'
                  //.handle(buildOutput(jmsConnectionFactory, 2))
                  .get();
          return flow;
      }
  
  
      private JmsSendingMessageHandler buildOutput(ConnectionFactory jmsConnectionFactory, int i){
          return Jms.outboundAdapter(jmsConnectionFactory)
                  .destination(OUTPUT_QUEUE_PREFIX + i).get();
      }
  }
  </code></pre>