camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Eric Bouer <>
Subject Still problems with InOut JMS
Date Mon, 06 Jul 2009 22:15:33 GMT

I finally had time to try again the JMSReplyTo issue.
Going back to .
I understand that I can set JMSReplyTo header of InOnly message and also
send it with preserveMessageQos=true. but then camel won't really wait for a
response(i.e won't get an exception when a timeout occures)
I do want camel to correlate JMS messages and wait for reply but I want to
have control on the JMSReplyTo.
Can I set the JMSReplyTo of a route that has InOut pattern ?
It seems to ignore everything I try.
I'm providing a test case that goes like this:
A non-camel JMS client  says "Hello I'm here" which is InOnly message.
(Advisory in real app)
The server asks  "What's your name?" which is InOut Message, the non-camel
client should reply it's name.
I want to get the reply "my name is .." in specific queue and not the temp
one camel creates by default.
I'm not using JmsTemplate to send the request on purpose.
Thanks again.

============ Test Code ========
package org.apache.camel.component.jms;

import javax.jms.Destination;
import javax.jms.TextMessage;
import org.apache.activemq.camel.component.ActiveMQComponent;
import org.apache.camel.CamelContext;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.test.CamelTestSupport;

import org.springframework.jms.core.JmsTemplate;
import static

public class JmsCustomJMSReplyToInOutTest extends CamelTestSupport {

    private ActiveMQComponent amq;
    private static String MQURI =
//    private static String MQURI = "tcp://amq1:61616";

    public void testCustomJMSReplyToInOut() throws Exception {
        MockEndpoint mock = getMockEndpoint("mock:result");
        mock.expectedBodiesReceived("My name is Arnio");
        // start a inOnly route
        template.sendBody("activemq:queue:hello", "Hello, I'm here");
        // now consume using something that is not Camel

        JmsTemplate jms = new
        TextMessage msg = (TextMessage) jms.receive("nameRequestor");
        assertEquals("What's your name", msg.getText());
        // there should be a JMSReplyTo so we know where to send the reply
        Destination replyTo = msg.getJMSReplyTo();
        System.out.println("Reply will be sent to " + replyTo.toString());
        assertEquals("queue://nameReplyQueue", replyTo.toString());
        // send reply
        template.sendBody("activemq:" + replyTo.toString(), "My name is

    protected RouteBuilder createRouteBuilder() throws Exception {
        return new RouteBuilder() {

            public void configure() throws Exception {
                        .process(new Processor() {
                        public void process(Exchange exchange) throws
Exception {
                            exchange.getOut().setBody("What's your name");
"nameReplyQueue"); //this should be enough
// maybe this ?
.setProperty("JMSReplyTo",constant("nameReplyQueue")) // or this ?
                        //this will force JMSReplyTo but won't correlate

   protected CamelContext createCamelContext() throws Exception {
        CamelContext camelContext = super.createCamelContext();
        amq = activeMQComponent(MQURI);
        camelContext.addComponent("activemq", amq);
        return camelContext;

View this message in context:
Sent from the Camel - Users mailing list archive at

View raw message