P.S. I see that the header name I used in the example I pasted was "replyTo". Note that I have also tried "JMSReplyTo" with the same result.

Jim

On 5/23/2011 4:07 PM, Jim Newsham wrote:

Hi,

I'm using Camel 2.7.1 and ActiveMQ 5.5.0. I've been trying to set the jms reply-to destination by message header and have had no luck. The documentation at http://camel.apache.org/jms.html seems to imply this is possible, so perhaps I'm not doing it quite correctly.

I created a very simple stand-alone test to show what I'm trying to do (and what's not working). In the output, I expect to see that the reply-to queue is "queue://myqueue", but instead it is a temporary queue.

Any suggestions would be greatly appreciated.

Thanks,
Jim

[1] Test case

package test;

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.ProducerTemplate;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.DefaultCamelContext;
import org.apache.log4j.Logger;

public class TestReplyToHeader {

private static final Logger LOGGER = Logger.getLogger(TestReplyToHeader.class);

  public static void main(String... args) throws Exception {
    CamelContext context = new DefaultCamelContext();
    context.addComponent("activemq",
ActiveMQComponent.activeMQComponent("vm://localhost?broker.persistent=false"));

    context.addRoutes(new RouteBuilder() {
      @Override
      public void configure() throws Exception {
        from("direct:a")
          .process(new Processor() {
            @Override
            public void process(Exchange exchange) throws Exception {
              exchange.getIn().setHeader("replyTo", "queue://myqueue");
            }
          })
          .to("activemq:queue:b");

        from("activemq:queue:b")
          .log("received request: ${body}")
          .log("reply-to: ${headers.JMSReplyTo}")
          .setBody(simple("polo"));
      }
    });
    context.start();

    ProducerTemplate template = context.createProducerTemplate();
String reply = template.requestBody("direct:a", "marco", String.class);
    LOGGER.info("received reply: " + reply);
  }

}

[2]  Tail of output

- Using JmsReplyManager: org.apache.camel.component.jms.reply.TemporaryQueueReplyManager@1db5ec to process replies from temporary queue
- received request: marco
- reply-to: temp-queue://ID:rsi-eng-newsham-57636-1306202592226-2:2:1
- received reply: polo



Reply via email to