title: Apache Camel not sending reply for incoming message
body: <p>I have Camel route which listens for incoming JMS messages. For some reason, the route doesn't send response to the JMS replyTo address. In the following example, the program hangs waiting for the reply message to be arrived at temporary destination. How do I make the JMS-listening route to handle the messages InOut-fashion?</p>
  
  <pre><code>@Component("testRouteBuilder")
  public class TestRouteBuilder extends RouteBuilder {
  
      @SuppressWarnings("unchecked")
      @Override
      public void configure() throws Exception {
  
          from("timer://foo?delay=2000")
              .setBody(simple("hello"))
              .log("request: ${body}")
              .to("bean://jmsbean")
              .log("reply: ${body}");
  
          from("jms://queue:dest")
  //          .setExchangePattern(ExchangePattern.InOut) // Not working
              .log("got message")
              .log("${headers}")
              .setBody(constant("reply"));
      }
  
      @Component("jmsbean")
      public static class JmsBean {
  
          @Autowired
          ConnectionFactory jmsServer1;
  
          @Autowired
          ConnectionFactory jmsServer2;
  
          public String testJms(@Body String body) throws JMSException {
  
              Connection conn = jmsServer1.createConnection();
              conn.start();
              Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
  
              Connection conn2 = jmsServer2.createConnection();
              conn2.start();
              Session session2 = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
  
              TemporaryQueue tempQueue = session2.createTemporaryQueue();
  
              TextMessage message = session.createTextMessage();
              message.setJMSCorrelationID("tuomas");
              message.setJMSReplyTo(tempQueue);
              message.setJMSMessageID("tuomas");
  
              Queue dest = session.createQueue("dest");
              MessageProducer producer = session.createProducer(dest);
              producer.send(message);
  
              session.close();
              conn.close();
  
              MessageConsumer consumer = session2.createConsumer(tempQueue, "tuomas");
              Message reply = consumer.receive();
  
              session2.close();
              conn2.close();
  
              return reply.getBody(String.class);
          }
      }
  }
  </code></pre>
  
  <p>.</p>
  
  <pre><code>2018-04-06 18:24:31.497  INFO 15256 --- [           main] t.springcamel.SpringcamelApplication     : Started SpringcamelApplication in 6.143 seconds (JVM running for 11.263)
  2018-04-06 18:24:33.456  INFO 15256 --- [2 - timer://foo] route1                                   : request: hello
  2018-04-06 18:24:33.503  INFO 15256 --- [sConsumer[dest]] route2                                   : got message
  2018-04-06 18:24:33.503  INFO 15256 --- [sConsumer[dest]] route2                                   : {breadcrumbId=ID-DESKTOP-LI5P50P-1523028268251-0-2, JMSCorrelationID=tuomas, JMSCorrelationIDAsBytes=tuomas, JMSDeliveryMode=2, JMSDestination=queue://dest, JMSExpiration=0, JMSMessageID=ID:DESKTOP-LI5P50P-51501-1523028271227-4:2:1:1:1, JMSPriority=4, JMSRedelivered=false, JMSReplyTo=temp-queue://ID:DESKTOP-LI5P50P-51501-1523028271227-4:3:1, JMSTimestamp=1523028273488, JMSType=null, JMSXGroupID=null, JMSXUserID=null}
  </code></pre>