JMSReplyTo is not set when explicitly set by user
-------------------------------------------------

                 Key: CAMEL-1773
                 URL: https://issues.apache.org/activemq/browse/CAMEL-1773
             Project: Apache Camel
          Issue Type: Bug
          Components: camel-jms
    Affects Versions: 2.0-M2
         Environment: jdk6u13 jdk6u14
            Reporter: Eric Bouer


By default camel sets the JMSReplyTo for InOut messages.
A user should be able to customize the JMSReplyTo  property. 
Camel always overrides the JMSReplyTo and sets it to a temp-queue regardless 
user settings.
=========== code Snippet =============
package com.mycompany.CamelExample;
import javax.jms.ConnectionFactory;
import org.apache.activemq.ActiveMQConnectionFactory;

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.component.jms.JmsConstants;
import org.apache.camel.impl.DefaultCamelContext;
public final class App {
  
    public static void main(String args[]) throws Exception {

        CamelContext context = new DefaultCamelContext();
        ConnectionFactory connectionFactory =  new 
ActiveMQConnectionFactory("tcp://amq1:61616");
        final String TEST_QUEUE_1 = "test-jms:queue:test1";
        final String TEST_QUEUE_2 = "test-jms:queue:test2";
        final String REPLY_QUEUE = "queue:myResponseQueue";
        context.addComponent("test-jms", 
ActiveMQComponent.jmsComponent(connectionFactory));
        context.addRoutes(new RouteBuilder() {
            public void configure() {
             from(TEST_QUEUE_1)
                     .process(new Processor() { public void process(Exchange 
exchange) throws Exception {
                        System.out.println(exchange.getIn().getBody());
                        exchange.getOut().setBody("Hello again");
                        
exchange.setProperty(JmsConstants.JMS_REPLY_DESTINATION, REPLY_QUEUE);
                    }
                })
                .to(TEST_QUEUE_2);
                
                from(TEST_QUEUE_2)
                        .process(new Processor() {  public void 
process(Exchange exchange) throws Exception {
                        String body = (String) exchange.getIn().getBody();
                        System.out.println("direct:a got process" + 
body.toString());
                        exchange.getIn().setBody("lolo");
                        System.out.println(exchange.getIn().getHeaders());
                        exchange.getIn().setBody("Bye World");
                        // the reply destination is set as a property on the 
exchange while we process it
                        String ReplyTo = 
exchange.getProperty(JmsConstants.JMS_REPLY_DESTINATION).toString();
                         if (!ReplyTo.equalsIgnoreCase(REPLY_QUEUE)) {
                        //assert
                              throw new Exception("JMSReplyTo is not set 
correctly: got:" + ReplyTo
                                     + " Expexting:" +  REPLY_QUEUE);
                         }
                    }});
               
            }});
        ProducerTemplate template = context.createProducerTemplate();
        context.start();
        Thread.sleep(2000);
        String requestBody =  (String) template.requestBody(TEST_QUEUE_1, 
"Hello world", String.class);
    }
}
======== Log ==============
2:19:41,559  INFO DefaultCamelContext:135 - JMX enabled. Using 
InstrumentationLifecycleStrategy.
22:19:41,656  INFO DefaultCamelContext:875 - Apache Camel 2.0-M2 
(CamelContext:camel-1) is starting
22:19:42,251  INFO DefaultCamelContext:868 - Apache Camel 2.0-M2 
(CamelContext:camel-1) started
22:19:44,453 DEBUG JmsProducer:202 - Using JMS API v1.1
22:19:44,515 DEBUG JmsConfiguration$CamelJmsTemplate:469 - Executing callback 
on JMS Session: ActiveMQSession 
{id=ID:niso-42103-1246303182016-0:3:1,started=false}
22:19:44,519 DEBUG JmsBinding:370 - Using JmsMessageType: Text
22:19:44,525 DEBUG JmsProducer:188 - Endpoint[test-jms:queue:test1] sending JMS 
message: ActiveMQTextMessage {commandId = 0, responseRequired = false, 
messageId = null, originalDestination = null, originalTransactionId = null, 
producerId = null, destination = null, transactionId = null, expiration = 0, 
timestamp = 0, arrival = 0, brokerInTime = 0, brokerOutTime = 0, correlationId 
= ID-niso-45344-1246303184258-2-0, replyTo = 
temp-queue://ID:niso-42103-1246303182016-0:2:1, persistent = false, type = 
null, priority = 0, groupID = null, groupSequence = 0, targetConsumerId = null, 
compressed = false, userID = null, content = null, marshalledProperties = null, 
dataStructure = null, redeliveryCounter = 0, size = 0, properties = null, 
readOnlyProperties = false, readOnlyBody = false, droppable = false, text = 
Hello world}
22:19:44,527 DEBUG JmsConfiguration$CamelJmsTemplate:202 - Sending created 
message: ActiveMQTextMessage {commandId = 0, responseRequired = false, 
messageId = null, originalDestination = null, originalTransactionId = null, 
producerId = null, destination = null, transactionId = null, expiration = 0, 
timestamp = 0, arrival = 0, brokerInTime = 0, brokerOutTime = 0, correlationId 
= ID-niso-45344-1246303184258-2-0, replyTo = 
temp-queue://ID:niso-42103-1246303182016-0:2:1, persistent = false, type = 
null, priority = 0, groupID = null, groupSequence = 0, targetConsumerId = null, 
compressed = false, userID = null, content = null, marshalledProperties = null, 
dataStructure = null, redeliveryCounter = 0, size = 0, properties = null, 
readOnlyProperties = false, readOnlyBody = false, droppable = false, text = 
Hello world}
22:19:44,564 DEBUG EndpointMessageListener:66 - Endpoint[test-jms:queue:test1] 
consumer receiving JMS message: ActiveMQTextMessage {commandId = 5, 
responseRequired = true, messageId = ID:niso-42103-1246303182016-0:3:1:1:1, 
originalDestination = null, originalTransactionId = null, producerId = 
ID:niso-42103-1246303182016-0:3:1:1, destination = queue://test1, transactionId 
= null, expiration = 1246303204528, timestamp = 1246303184528, arrival = 0, 
brokerInTime = 1246303121068, brokerOutTime = 1246303121099, correlationId = 
ID-niso-45344-1246303184258-2-0, replyTo = 
temp-queue://ID:niso-42103-1246303182016-0:2:1, persistent = true, type = null, 
priority = 4, groupID = null, groupSequence = 0, targetConsumerId = null, 
compressed = false, userID = null, content = null, marshalledProperties = null, 
dataStructure = null, redeliveryCounter = 0, size = 0, properties = null, 
readOnlyProperties = true, readOnlyBody = true, droppable = false, text = Hello 
world}
Hello world
22:19:44,853 DEBUG JmsProducer:202 - Using JMS API v1.1
22:19:44,853 DEBUG JmsConfiguration$CamelJmsTemplate:469 - Executing callback 
on JMS Session: ActiveMQSession 
{id=ID:niso-42103-1246303182016-0:1:1,started=true}
22:19:44,854 DEBUG JmsBinding:370 - Using JmsMessageType: Text
22:19:44,854 DEBUG JmsProducer:188 - Endpoint[test-jms:queue:test2] sending JMS 
message: ActiveMQTextMessage {commandId = 0, responseRequired = false, 
messageId = null, originalDestination = null, originalTransactionId = null, 
producerId = null, destination = null, transactionId = null, expiration = 0, 
timestamp = 0, arrival = 0, brokerInTime = 0, brokerOutTime = 0, correlationId 
= ID-niso-45344-1246303184258-4-0, replyTo = 
temp-queue://ID:niso-42103-1246303182016-0:4:1, persistent = false, type = 
null, priority = 0, groupID = null, groupSequence = 0, targetConsumerId = null, 
compressed = false, userID = null, content = null, marshalledProperties = null, 
dataStructure = null, redeliveryCounter = 0, size = 0, properties = null, 
readOnlyProperties = false, readOnlyBody = false, droppable = false, text = 
Hello again}
22:19:44,855 DEBUG JmsConfiguration$CamelJmsTemplate:202 - Sending created 
message: ActiveMQTextMessage {commandId = 0, responseRequired = false, 
messageId = null, originalDestination = null, originalTransactionId = null, 
producerId = null, destination = null, transactionId = null, expiration = 0, 
timestamp = 0, arrival = 0, brokerInTime = 0, brokerOutTime = 0, correlationId 
= ID-niso-45344-1246303184258-4-0, replyTo = 
temp-queue://ID:niso-42103-1246303182016-0:4:1, persistent = false, type = 
null, priority = 0, groupID = null, groupSequence = 0, targetConsumerId = null, 
compressed = false, userID = null, content = null, marshalledProperties = null, 
dataStructure = null, redeliveryCounter = 0, size = 0, properties = null, 
readOnlyProperties = false, readOnlyBody = false, droppable = false, text = 
Hello again}
22:19:44,895 DEBUG EndpointMessageListener:66 - Endpoint[test-jms:queue:test2] 
consumer receiving JMS message: ActiveMQTextMessage {commandId = 7, 
responseRequired = true, messageId = ID:niso-42103-1246303182016-0:1:1:1:1, 
originalDestination = null, originalTransactionId = null, producerId = 
ID:niso-42103-1246303182016-0:1:1:1, destination = queue://test2, transactionId 
= null, expiration = 1246303204855, timestamp = 1246303184855, arrival = 0, 
brokerInTime = 1246303121399, brokerOutTime = 1246303121433, correlationId = 
ID-niso-45344-1246303184258-4-0, replyTo = 
temp-queue://ID:niso-42103-1246303182016-0:4:1, persistent = true, type = null, 
priority = 4, groupID = null, groupSequence = 0, targetConsumerId = null, 
compressed = false, userID = null, content = null, marshalledProperties = null, 
dataStructure = null, redeliveryCounter = 0, size = 0, properties = null, 
readOnlyProperties = true, readOnlyBody = true, droppable = false, text = Hello 
again}
direct:a got processHello again
{JMSXGroupID=null, JMSCorrelationID=ID-niso-45344-1246303184258-4-0, 
JMSType=null, JMSExpiration=1246303204855, 
JMSMessageID=ID:niso-42103-1246303182016-0:1:1:1:1, JMSRedelivered=false, 
JMSDeliveryMode=2, JMSPriority=4, 
JMSReplyTo=temp-queue://ID:niso-42103-1246303182016-0:4:1, 
JMSTimestamp=1246303184855, JMSDestination=queue://test2}
22:19:44,905 ERROR EndpointMessageListener:207 - java.lang.Exception: 
JMSReplyTo is not set correctly: 
got:temp-queue://ID:niso-42103-1246303182016-0:4:1 
Expexting:queue:myResponseQueue
org.apache.camel.RuntimeCamelException: java.lang.Exception: JMSReplyTo is not 
set correctly: got:temp-queue://ID:niso-42103-1246303182016-0:4:1 
Expexting:queue:myResponseQueue
        at 
org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:986)
        at 
org.apache.camel.component.jms.EndpointMessageListener.onMessage(EndpointMessageListener.java:101)
        at 
org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:543)
        at 
org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:482)
        at 
org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:451)
        at 
org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:323)
        at 
org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:261)
        at 
org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:982)
        at 
org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:881)
        at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.Exception: JMSReplyTo is not set correctly: 
got:temp-queue://ID:niso-42103-1246303182016-0:4:1 
Expexting:queue:myResponseQueue
        at com.mycompany.CamelExample.App$1$2.process(App.java:45)
        at 
org.apache.camel.processor.interceptor.StreamCachingInterceptor.process(StreamCachingInterceptor.java:52)
        at 
org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:61)
        at 
org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:61)
        at 
org.apache.camel.processor.DefaultErrorHandler.process(DefaultErrorHandler.java:52)
        at 
org.apache.camel.processor.DefaultChannel.process(DefaultChannel.java:147)
        at 
org.apache.camel.processor.UnitOfWorkProcessor.processNext(UnitOfWorkProcessor.java:54)
        at 
org.apache.camel.processor.DelegateProcessor.process(DelegateProcessor.java:48)
        at 
org.apache.camel.component.jms.EndpointMessageListener.onMessage(EndpointMessageListener.java:81)
        ... 8 more
22:19:44,906  WARN DefaultMessageListenerContainer:646 - Execution of JMS 
message listener failed
org.apache.camel.RuntimeCamelException: java.lang.Exception: JMSReplyTo is not 
set correctly: got:temp-queue://ID:niso-42103-1246303182016-0:4:1 
Expexting:queue:myResponseQueue
====


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to