You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by igoldsmith <ia...@carragold.com> on 2010/11/04 17:11:28 UTC

JMS ReplyTo not sent for InOnly Pattern

I'm trying to setup a fairly simple scenario where I use Camel to pull a
document out of a directory on the file system and send it to a JMS queue. 
I have an application that will read the message from the queue and send a
response to the queue specified in the replyTo header of the inbound
message.  I will then specify another route in Camel that will read the
response from the replyTo queue and drop this into another directory on the
file system.

The problem I have is that I cannot seem to get Camel to set the replyTo
header for the InOnly pattern that this scenario forces.  Of course, if
anyone can think of a better way of building this request response pattern
for file->queue->file then I'm all ears.

I've found a fair amount of information on this, including Camel-3012 and
related threads.  I'm currently using ActiveMQ 5.4.1 with Camel 2.5.0.  I
have a route configured using the following:

        <route autoStartup="true" id="File2JMS">
            <from uri="file:/home/soa/camel"/>
            <to
uri="activemq:queue:borrower.req?jmsMessageType=Text&amp;replyTo=que
ue:borrower.resp&amp;preserveMessageQos=true" pattern="InOnly"/>
        </route>

The only reason I have the pattern specified is that I've used that
attribute to force InOut to verify that the JMSReplyTo header does get set
correctly with this pattern.

>From the docs it seems that I should also be able to use disableReplyTo=true
with the InOut pattern, but this doesn't include the ReplyTo header either.

The DEBUG level logging for this shows the correct endpoint, but as you can
see doesn't include the replyTo header in the message that gets sent:

2010-11-04 12:05:51,425 | DEBUG | About to process file:
GenericFile[/home/soa/camel/testmsg] using exchange:
Exchange[/home/soa/camel/testmsg] |
org.apache.camel.component.file.FileConsumer | Camel Thread 0 -
file:///home/soa/camel
2010-11-04 12:05:51,442 | DEBUG | >>>>
Endpoint[activemq://queue:borrower.req?jmsMessageType=Text&preserveMessageQos=true&replyTo=queue%3Aborrower.resp]
Exchange[/home/soa/camel/testmsg] | org.apache.camel.processor.SendProcessor
| Camel Thread 0 - file:///home/soa/camel
2010-11-04 12:05:51,462 | INFO  | Connector vm://localhost Started |
org.apache.activemq.broker.TransportConnector | Camel Thread 0 -
file:///home/soa/camel
2010-11-04 12:05:51,597 | DEBUG | Executing callback on JMS Session:
ActiveMQSession
{id=ID:pmdemo.soa.local-55577-1288886465168-4:0:1,started=false} |
org.apache.camel.component.jms.JmsConfiguration$CamelJmsTemplate | Camel
Thread 0 - file:///home/soa/camel
2010-11-04 12:05:51,649 | DEBUG | Sending JMS message to:
queue://borrower.req with 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 = null, replyTo = null,
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 = {CamelFileLength=21,
CamelFileParent=/home/soa/camel, CamelFileLastModified=Thu Nov 04 12:05:51
EDT 2010, CamelFileRelativePath=/home/soa/camel/testmsg,
CamelFileAbsolute=true, CamelFileNameOnly=testmsg, CamelFileName=testmsg,
CamelFilePath=/home/soa/camel/testmsg,
CamelFileAbsolutePath=/home/soa/camel/testmsg}, readOnlyProperties = false,
readOnlyBody = false, droppable = false, text = Another test message
} | org.apache.camel.component.jms.JmsConfiguration$CamelJmsTemplate | Camel
Thread 0 - file:///home/soa/camel

If anyone has any ideas as to what I'm doing wrong, or any thoughts on a
better way to deliver my scenario then I'm all ears.  Thanks in advance.

Ian

-- 
View this message in context: http://camel.465427.n5.nabble.com/JMS-ReplyTo-not-sent-for-InOnly-Pattern-tp3250344p3250344.html
Sent from the Camel - Users (activemq) mailing list archive at Nabble.com.

Re: JMS ReplyTo not sent for InOnly Pattern

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

I have created a ticket to track this
https://issues.apache.org/jira/browse/CAMEL-3462

And looks like I got a bit of time to look at this.


On Sun, Nov 7, 2010 at 1:53 AM, igoldsmith <ia...@carragold.com> wrote:
>
> I'm not sure what you mean by creating a sample project.  I'm not really a
> developer.  I'm a product manager.
>
> I think that the specification of replyTo on an endpoint should always
> ensure that there is a replyTo specified in messages sent by the
> JMSProducer, because if the route creator specifies it, then that is what
> they intend.  The only decision should be what to do in the event that there
> is already a replyTo header in the message.
>
> I would argue that the default behavior should be to always use the value
> specified in the endpoint (i.e. override any value provided in the
> exchange).  If the administrator wants to reverse this default they could
> use the preserveMessageQos=true option, although replyTo doesn't really seem
> to fit into the category of QoS.
>
> I think adding the following code to the JMS Producer right before the
> initiation of the messageCreator might do the job:
>
>        // if the endpoint contains a replyTo header then we'll always use
> it
>        // unless the preserveMessageQos flag is set, in which case we'll
> only use it
>        // if the exchange doesn't contain a replyTo
>        if (endpoint.getReplyTo() != null) {
>                if (!endpoint.isPreserveMessageQos() ||
> (exchange.getIn().getHeader("JMSReplyTo") == null)) {
>                        exchange.getIn().setHeader("JMSReplyTo", endpoint.getReplyTo());
>                }
>        }
>
> Not the most graceful solution, but I think it works.
>
> Ian
>
>
> Claus Ibsen-2 wrote:
>>
>>
>> There may be an issue on the producer side to send a message as InOnly
>> to a JMS destination and preserving the JMSReplyTo header.
>> Fell free to create a little sample project with a couple of routes
>> which highlights your intention.
>>
>> Then we can use that for unit tests and implementing this in camel-jms
>> if an option is missing.
>>
>>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/JMS-ReplyTo-not-sent-for-InOnly-Pattern-tp3250344p3253597.html
> Sent from the Camel - Users (activemq) mailing list archive at Nabble.com.
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Re: JMS ReplyTo not sent for InOnly Pattern

Posted by igoldsmith <ia...@carragold.com>.
I'm not sure what you mean by creating a sample project.  I'm not really a
developer.  I'm a product manager.

I think that the specification of replyTo on an endpoint should always
ensure that there is a replyTo specified in messages sent by the
JMSProducer, because if the route creator specifies it, then that is what
they intend.  The only decision should be what to do in the event that there
is already a replyTo header in the message.  

I would argue that the default behavior should be to always use the value
specified in the endpoint (i.e. override any value provided in the
exchange).  If the administrator wants to reverse this default they could
use the preserveMessageQos=true option, although replyTo doesn't really seem
to fit into the category of QoS.  

I think adding the following code to the JMS Producer right before the
initiation of the messageCreator might do the job:

        // if the endpoint contains a replyTo header then we'll always use
it
        // unless the preserveMessageQos flag is set, in which case we'll
only use it
        // if the exchange doesn't contain a replyTo
        if (endpoint.getReplyTo() != null) {
        	if (!endpoint.isPreserveMessageQos() ||
(exchange.getIn().getHeader("JMSReplyTo") == null)) {
        		exchange.getIn().setHeader("JMSReplyTo", endpoint.getReplyTo());
        	}
        }

Not the most graceful solution, but I think it works.

Ian 


Claus Ibsen-2 wrote:
> 
> 
> There may be an issue on the producer side to send a message as InOnly
> to a JMS destination and preserving the JMSReplyTo header.
> Fell free to create a little sample project with a couple of routes
> which highlights your intention.
> 
> Then we can use that for unit tests and implementing this in camel-jms
> if an option is missing.
> 
> 

-- 
View this message in context: http://camel.465427.n5.nabble.com/JMS-ReplyTo-not-sent-for-InOnly-Pattern-tp3250344p3253597.html
Sent from the Camel - Users (activemq) mailing list archive at Nabble.com.

Re: JMS ReplyTo not sent for InOnly Pattern

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

I haven't had time to look into this.

There may be an issue on the producer side to send a message as InOnly
to a JMS destination and preserving the JMSReplyTo header.
Fell free to create a little sample project with a couple of routes
which highlights your intention.

Then we can use that for unit tests and implementing this in camel-jms
if an option is missing.



On Thu, Nov 4, 2010 at 9:35 PM, igoldsmith <ia...@carragold.com> wrote:
>
> I've been reading through the source for the JmsProducer class and don't see
> how this can ever work for InOnly.  It seems that the code is looking at the
> inMessage in the Exchange for a ReplyTo header, and not checking the
> endpoint definition to see if it's forcing the ReplyTo in the endpoint
> definition.
>
>                // if the binding did not create the reply to then we have
> to try to create it here
>                String replyTo = exchange.getIn().getHeader("JMSReplyTo",
> String.class);
>
> Contrasting this with the InOut model where it uses endpoint.getReplyTo() to
> find the replyTo queue.
>
> Am I missing something?
>
> Ian
> --
> View this message in context: http://camel.465427.n5.nabble.com/JMS-ReplyTo-not-sent-for-InOnly-Pattern-tp3250344p3250848.html
> Sent from the Camel - Users (activemq) mailing list archive at Nabble.com.
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Re: JMS ReplyTo not sent for InOnly Pattern

Posted by igoldsmith <ia...@carragold.com>.
I've been reading through the source for the JmsProducer class and don't see
how this can ever work for InOnly.  It seems that the code is looking at the
inMessage in the Exchange for a ReplyTo header, and not checking the
endpoint definition to see if it's forcing the ReplyTo in the endpoint
definition.

                // if the binding did not create the reply to then we have
to try to create it here
                String replyTo = exchange.getIn().getHeader("JMSReplyTo",
String.class);

Contrasting this with the InOut model where it uses endpoint.getReplyTo() to
find the replyTo queue.

Am I missing something?

Ian
-- 
View this message in context: http://camel.465427.n5.nabble.com/JMS-ReplyTo-not-sent-for-InOnly-Pattern-tp3250344p3250848.html
Sent from the Camel - Users (activemq) mailing list archive at Nabble.com.