camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "S.R." <>
Subject Problem with InOut pattern and JMS component
Date Sun, 06 Jul 2008 13:42:35 GMT


I'm new to Camel, but this problem looks like the bug in JMS component.

I have a following route:


1. Initial message producer (IMP) sends the message (with JMSReplyTo field
set to "jms:replies") to the jms:sourceQueue, and starts listening the
jms:replies queue for replies;
2. Camel router gets the message from jms:sourceQueue and passes it to the
testBean.test(exchange) method, that creates new message and set it to
exchange.out field (see code bellow);
3. New Out message sends as In message to the jms:AQueue. Then other
listener (AQueueListener, see code bellow) listens the jms:AQueue for new
message and replies to its JMSReplyTo destination (that is 
changed by Camel to some temp dest.)
4. Camel gets reply from AQueueListener (from temp Camel's queue) and sends
it as In message to jms:BQueue;
5. The third listener (BQueueListener) listens the jms:BQueue message and
replies to its JMSReplyTo destination (that was also replaced with Camel's
temp queue);
6. Last step - Camel gets reply from BQueueListener (also from temp Camel's
queue) and sends it as a response message to the jms:replies queue that is
listened by IMP.

So If IMP sends the message like "abcd", finally it will get response like
"[BQueueListener] Reply for [[AQueueListener] Reply for [[testBean] Reply
for [abcd]]]"

That's all OK, but...

Then I want to change the endpoint's order to set JMS endpoint to the first
place, like:


It is obviously that if IMP would send message "abcd", it would get response
like "[BQueueListener] Reply for [[testBean] Reply for [[AQueueListener]
Reply for [abcd]]]", 
but actually it gets the "[AQueueListener] Reply for [abcd]"!

It means that after AQueueListener has responded on the message "abcd", the
response "[AQueueListener] Reply for [abcd]" is immediately sent to the
IMP's jms:replies queue as well as to further endpoints of route (I checked
it by loging); and after BQueueListener (last element in chain) has
responded on the message, the response isn't sent to the IMP's jms:replies.

Why? Is that expected behaviour? Or this is a bug?

Code Examples:
AQueueListener and BQueueListener (the same as AQueueListener): 
public class AQueueListener implements MessageListener {
    private JmsTemplate jmsTemplate = ...;
    public void onMessage(Message message) {
            final TextMessage msg = (TextMessage) message;
            try {
                if (msg.getJMSReplyTo() != null) {
                    // do reply
"[AQueueListener] Reply for [" + msg.getText() + "]",  new
MessagePostProcessor() {
                            public Message postProcessMessage(Message
message) throws JMSException {
                            return message;
            } catch (JMSException e) {
                throw new RuntimeException(e);
class TestBean {
    public void test(Exchange ex) {
        Message msg = new JmsMessage();
        msg.setBody("[testBean] Reply for [" +
ex.getIn().getBody().toString() + "]");

I'm looking forward to your response.

Thanks in advance.

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

View raw message