I'm testing out examples of using the JMS Request/Reply with Camel and ActiveMQ. I can get the example to work when camel creates the listener for you. ie.
\[code\]from("direct:entryPoint").inOut("jms:queue:A");from("jms:queue:A"). process(new Processor() { @Override public void process(Exchange exchange) throws Exception { exchange.getIn().setBody("Hello World."); } });\[/code\]
The issue I'm having now is that I can't get the JMS Request/Reply working with a MessageListener that exists outside of Camel's jvm. The connection times out waiting for a reply. I made sure that the MessageListener is sending the reply to the replyTo queue and I'm also setting the correlationId. What am I doing wrong here? I've googled for days trying to figure this out with no luck. Thanks ahead of time for your help.Below is the route I'm using and I also put the MessageListener logic below as well.\[code\]from("direct:entryPoint"). inOut("jms:queue:B?concurrentConsumers=4&requestTimeout=240000");\[/code\]MessageListener onMessage for queue B:\[code\]@Overridepublic void onMessage(Message message) { String msg = null; ObjectMapper mapper = new ObjectMapper(); mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, true); String jsonOutput = null; try{ msg = ((TextMessage) message).getText(); //convert message payload to purchase order PurchaseOrder order = mapper.readValue(msg, PurchaseOrder.class); //Set the id to see if the request reply worked. order.setOrderId(BigInteger.valueOf(111111111)); if(message.getJMSReplyTo() != null){ Map<String, Object> headers = new HashMap<String, Object>(); headers.put("JMSCorrelationID", message.getJMSCorrelationID()); headers.put("JMSReplyTo", message.getJMSReplyTo().toString()); jsonOutput = mapper.writeValueAsString(order); //Camel runs on the external jvm so leverage the producerTemplate. producerTemplate. sendBodyAndHeaders("jms:"+ message.getJMSReplyTo().toString(), jsonOutput, headers); } } catch(Exception e){ logger.fatal(e.getMessage()); try { if(message.getJMSReplyTo() != null){ Map<String, Object> headers = new HashMap<String, Object>(); headers.put("JMSCorrelationID", message.getJMSCorrelationID()); producerTemplate. sendBodyAndHeaders("jms:"+ message.getJMSReplyTo().toString(), e.getMessage(), headers); } } catch (JMSException e1) { logger.fatal(e1.getMessage()); } catch (Exception e1) { logger.fatal(e1.getMessage()); } }}\[/code\]
\[code\]from("direct:entryPoint").inOut("jms:queue:A");from("jms:queue:A"). process(new Processor() { @Override public void process(Exchange exchange) throws Exception { exchange.getIn().setBody("Hello World."); } });\[/code\]
The issue I'm having now is that I can't get the JMS Request/Reply working with a MessageListener that exists outside of Camel's jvm. The connection times out waiting for a reply. I made sure that the MessageListener is sending the reply to the replyTo queue and I'm also setting the correlationId. What am I doing wrong here? I've googled for days trying to figure this out with no luck. Thanks ahead of time for your help.Below is the route I'm using and I also put the MessageListener logic below as well.\[code\]from("direct:entryPoint"). inOut("jms:queue:B?concurrentConsumers=4&requestTimeout=240000");\[/code\]MessageListener onMessage for queue B:\[code\]@Overridepublic void onMessage(Message message) { String msg = null; ObjectMapper mapper = new ObjectMapper(); mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, true); String jsonOutput = null; try{ msg = ((TextMessage) message).getText(); //convert message payload to purchase order PurchaseOrder order = mapper.readValue(msg, PurchaseOrder.class); //Set the id to see if the request reply worked. order.setOrderId(BigInteger.valueOf(111111111)); if(message.getJMSReplyTo() != null){ Map<String, Object> headers = new HashMap<String, Object>(); headers.put("JMSCorrelationID", message.getJMSCorrelationID()); headers.put("JMSReplyTo", message.getJMSReplyTo().toString()); jsonOutput = mapper.writeValueAsString(order); //Camel runs on the external jvm so leverage the producerTemplate. producerTemplate. sendBodyAndHeaders("jms:"+ message.getJMSReplyTo().toString(), jsonOutput, headers); } } catch(Exception e){ logger.fatal(e.getMessage()); try { if(message.getJMSReplyTo() != null){ Map<String, Object> headers = new HashMap<String, Object>(); headers.put("JMSCorrelationID", message.getJMSCorrelationID()); producerTemplate. sendBodyAndHeaders("jms:"+ message.getJMSReplyTo().toString(), e.getMessage(), headers); } } catch (JMSException e1) { logger.fatal(e1.getMessage()); } catch (Exception e1) { logger.fatal(e1.getMessage()); } }}\[/code\]