camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kumaap <amitesh.a.ku...@gmail.com>
Subject Setting JMS ReplyTo
Date Thu, 02 Sep 2010 10:16:53 GMT

Camel version 2.4

I'm trying to set the JMS reply To. But it seems to be ignoring the
property.
Ive been reading some posts but still cant get it to work.

In my use case my route subscribes from a custom component and publishes to
a JMS queue.

Ive tried setting the header and also setting the replTo property

Ive provided this test code that shows teh properties not getting set 

package sandbox;

import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.camel.*;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.jms.JmsComponent;
import org.apache.camel.component.jms.JmsMessageType;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.spring.SpringCamelContext;
import org.apache.camel.test.junit4.CamelTestSupport;
import org.junit.Assert;
import org.junit.Before;
import org.springframework.context.support.GenericApplicationContext;


public class JMSReplyToTest extends CamelTestSupport {

    private ActiveMQConnectionFactory factory;
    private SpringCamelContext camelContext;

    @EndpointInject(uri = "mock:result")
    protected MockEndpoint resultEndpoint;

    @Produce(uri = "direct:start")
    protected ProducerTemplate template;

    @Before
    public void setUp() throws Exception {

        factory = new ActiveMQConnectionFactory("vm://local");
        super.setUp();
    }


    @org.junit.Test
    public void test() throws Exception {
        template.sendBody("test");
        resultEndpoint.expectedMessageCount(1);
       
Assert.assertTrue(resultEndpoint.getExchanges().get(0).getIn().getHeader("test")
!= null);
       
Assert.assertTrue(resultEndpoint.getExchanges().get(0).getIn().getHeader("test").equals("test"));
       
Assert.assertTrue(resultEndpoint.getExchanges().get(0).getIn().getHeader("JMSReplyTo")
!= null);
       
Assert.assertTrue(resultEndpoint.getExchanges().get(0).getIn().getHeader("JMSReplyTo").equals("SYSTEM.SOAP.RESPONSE.QUEUE"));
        resultEndpoint.assertIsSatisfied();
    }

    @Override
    protected CamelContext createCamelContext() throws Exception {
        GenericApplicationContext applicationContext = new
GenericApplicationContext();
        camelContext = new SpringCamelContext(applicationContext);
        JmsComponent jmsComponent = new JmsComponent();
        jmsComponent.setConnectionFactory(factory);
        applicationContext.getBeanFactory().registerSingleton("jms",
jmsComponent);
        return camelContext;
    }

    @Override
    protected RouteBuilder createRouteBuilder() {
        return new RouteBuilder() {
            public void configure() {
                from("direct:start").setHeader("JMSReplyTo",
constant("queue:SYSTEM.SOAP.RESPONSE.QUEUE")).setHeader("test",
constant("test")).to("jms:result?replyTo=queue://SYSTEM.SOAP.RESPONSE.QUEUE");
                from("jms:result").to("mock:result");
            }
        };
    }


}


-- 
View this message in context: http://camel.465427.n5.nabble.com/Setting-JMS-ReplyTo-tp2800345p2800345.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Mime
View raw message