You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Markus Mueller <M....@dzbw.de> on 2009/08/31 14:15:49 UTC

camel routing - messages stay in queue

I'm using camel 1.6 with servicemix 3.4. 

I've a simple route like this : 
from("activemq:queue:IN_QUEUE").to("activemq:queue:IN_BETWEEN_QUEUE").to("bean:resultBean");

So if I send a message to my IN_QUEUE it's routed to my IN_BETWEEN_QUEUE and
also reaches my resultBean. That's what I excpected. The Problem is,
although the message is processed in my resultBean (without Exception) it is
still in my IN_BETWEEN_QUEUE after all. 

If I delete the IN_BETWEEN_QUEUE and my route is like this :
from("activemq:queue:IN_QUEUE").to("bean:resultBean");
all is fine. The message is processed in my resultBean and after that
correctly disappears from my IN_QUEUE.

I can't understand that. Can anyone help ?
Markus
-- 
View this message in context: http://www.nabble.com/camel-routing---messages-stay-in-queue-tp25222552p25222552.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: camel routing - messages stay in queue

Posted by Markus Mueller <M....@dzbw.de>.
The polling consumer looks good. I'll try that.

Why do I do that ? Because I have one queue with a lot of messages
(IN_QUEUE). All these messages go to the same endpoint (the resultBean, it
connects to a host system). This endpoint (resultBean) has a dynamic
configuration (for various host systems), depending on the message content.
As each host system can be offline or can act as a slow consumer I sort each
message and send it to a special queue for each host configuration. So one
single slow (or even unavailable) host system doesn't slow down the whole
system.



Claus Ibsen-2 wrote:
> 
> On Mon, Aug 31, 2009 at 3:00 PM, Markus Mueller<M....@dzbw.de> wrote:
>>
>> Unfortunately, I can't see how to do it in the
>>    from A -> send to B
>>    from B -> send to C
>> way.
>>
>> My problem is, that the IN_BETWEEN_QUEUE is dynamic and depends on the
>> message. So my (a bit more more complex) configure looks like this :
>>
>>                from("activemq:queue:IN_QUEUE").process(new Processor() {
>>
>>                        public void process(Exchange exchange) throws
>> Exception {
>>
>>                                Message inMessage = exchange.getIn();
>>                                String routingInfo =
>> exchange.getIn().getBody().toString().substring(0,8);
>>                                String targetSystem =
>> TargetResolver.getInstance().getSpecificRoute(routingInfo );
>>                                Endpoint ep =
>> getContext().getEndpoint("activemq:queue:" +
>> targetSystem);
>>                                ProducerTemplate pt =
>> getContext().createProducerTemplate();
>>                                pt.send(ep, exchange);
>>                        }
>>
>>                });//.to("bean:resultBean");
>>
>> My Problem is, that I don't know the real name of my IN_BETWEEN_QUEUE
>> outside my process(...). So if it doesn't work in the
>>  from A -> send to B -> send to C
>> manner, I'll have to find another solution. But don't know how to right
>> now.
>>
> 
> Why do you want to send to a queue and then immediately retrieve it
> from the same queue?
> 
> Well what you do in the processor code is to use the consumer template
> to retrieve the "new message" on the queue.
> 
>                                 ConsumerTemplate ct =
> getContext().createConsumerTemplate();
>                                 Exchange consumed = ct.receive(ep);
> 
> 
> Take a look at polling consumer EIP:
> http://camel.apache.org/polling-consumer.html
> 
> 
>>
>>
>>
>>
>> Claus Ibsen-2 wrote:
>>>
>>> On Mon, Aug 31, 2009 at 2:15 PM, Markus Mueller<M....@dzbw.de>
>>> wrote:
>>>>
>>>> I'm using camel 1.6 with servicemix 3.4.
>>>>
>>>> I've a simple route like this :
>>>> from("activemq:queue:IN_QUEUE").to("activemq:queue:IN_BETWEEN_QUEUE").to("bean:resultBean");
>>>>
>>>> So if I send a message to my IN_QUEUE it's routed to my
>>>> IN_BETWEEN_QUEUE
>>>> and
>>>> also reaches my resultBean. That's what I excpected. The Problem is,
>>>> although the message is processed in my resultBean (without Exception)
>>>> it
>>>> is
>>>> still in my IN_BETWEEN_QUEUE after all.
>>>>
>>>> If I delete the IN_BETWEEN_QUEUE and my route is like this :
>>>> from("activemq:queue:IN_QUEUE").to("bean:resultBean");
>>>> all is fine. The message is processed in my resultBean and after that
>>>> correctly disappears from my IN_QUEUE.
>>>>
>>>> I can't understand that. Can anyone help ?
>>>
>>> Yeah what you are doing is like this
>>>      from A -> send to B -> send to C
>>>
>>> What you want to do is
>>>     from A -> send to B
>>>     from B -> send to C
>>>
>>>
>>> And thus you should use 2 routes
>>>
>>> from("activemq:queue:IN_QUEUE").to("activemq:queue:IN_BETWEEN_QUEUE");
>>>
>>> from("activemq:queue:IN_BETWEEN_QUEUE").to("bean:resultBean");
>>>
>>>
>>>
>>>
>>>> Markus
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/camel-routing---messages-stay-in-queue-tp25222552p25222552.html
>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>
>>>>
>>>
>>>
>>>
>>> --
>>> Claus Ibsen
>>> Apache Camel Committer
>>>
>>> Open Source Integration: http://fusesource.com
>>> Blog: http://davsclaus.blogspot.com/
>>> Twitter: http://twitter.com/davsclaus
>>>
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/camel-routing---messages-stay-in-queue-tp25222552p25223111.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
> 
> 
> 
> -- 
> Claus Ibsen
> Apache Camel Committer
> 
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
> 
> 

-- 
View this message in context: http://www.nabble.com/camel-routing---messages-stay-in-queue-tp25222552p25223608.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: camel routing - messages stay in queue

Posted by Claus Ibsen <cl...@gmail.com>.
On Mon, Aug 31, 2009 at 3:00 PM, Markus Mueller<M....@dzbw.de> wrote:
>
> Unfortunately, I can't see how to do it in the
>    from A -> send to B
>    from B -> send to C
> way.
>
> My problem is, that the IN_BETWEEN_QUEUE is dynamic and depends on the
> message. So my (a bit more more complex) configure looks like this :
>
>                from("activemq:queue:IN_QUEUE").process(new Processor() {
>
>                        public void process(Exchange exchange) throws Exception {
>
>                                Message inMessage = exchange.getIn();
>                                String routingInfo =
> exchange.getIn().getBody().toString().substring(0,8);
>                                String targetSystem =
> TargetResolver.getInstance().getSpecificRoute(routingInfo );
>                                Endpoint ep = getContext().getEndpoint("activemq:queue:" +
> targetSystem);
>                                ProducerTemplate pt = getContext().createProducerTemplate();
>                                pt.send(ep, exchange);
>                        }
>
>                });//.to("bean:resultBean");
>
> My Problem is, that I don't know the real name of my IN_BETWEEN_QUEUE
> outside my process(...). So if it doesn't work in the
>  from A -> send to B -> send to C
> manner, I'll have to find another solution. But don't know how to right now.
>

Why do you want to send to a queue and then immediately retrieve it
from the same queue?

Well what you do in the processor code is to use the consumer template
to retrieve the "new message" on the queue.

                                ConsumerTemplate ct =
getContext().createConsumerTemplate();
                                Exchange consumed = ct.receive(ep);


Take a look at polling consumer EIP:
http://camel.apache.org/polling-consumer.html


>
>
>
>
> Claus Ibsen-2 wrote:
>>
>> On Mon, Aug 31, 2009 at 2:15 PM, Markus Mueller<M....@dzbw.de> wrote:
>>>
>>> I'm using camel 1.6 with servicemix 3.4.
>>>
>>> I've a simple route like this :
>>> from("activemq:queue:IN_QUEUE").to("activemq:queue:IN_BETWEEN_QUEUE").to("bean:resultBean");
>>>
>>> So if I send a message to my IN_QUEUE it's routed to my IN_BETWEEN_QUEUE
>>> and
>>> also reaches my resultBean. That's what I excpected. The Problem is,
>>> although the message is processed in my resultBean (without Exception) it
>>> is
>>> still in my IN_BETWEEN_QUEUE after all.
>>>
>>> If I delete the IN_BETWEEN_QUEUE and my route is like this :
>>> from("activemq:queue:IN_QUEUE").to("bean:resultBean");
>>> all is fine. The message is processed in my resultBean and after that
>>> correctly disappears from my IN_QUEUE.
>>>
>>> I can't understand that. Can anyone help ?
>>
>> Yeah what you are doing is like this
>>      from A -> send to B -> send to C
>>
>> What you want to do is
>>     from A -> send to B
>>     from B -> send to C
>>
>>
>> And thus you should use 2 routes
>>
>> from("activemq:queue:IN_QUEUE").to("activemq:queue:IN_BETWEEN_QUEUE");
>>
>> from("activemq:queue:IN_BETWEEN_QUEUE").to("bean:resultBean");
>>
>>
>>
>>
>>> Markus
>>> --
>>> View this message in context:
>>> http://www.nabble.com/camel-routing---messages-stay-in-queue-tp25222552p25222552.html
>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>>
>> --
>> Claus Ibsen
>> Apache Camel Committer
>>
>> Open Source Integration: http://fusesource.com
>> Blog: http://davsclaus.blogspot.com/
>> Twitter: http://twitter.com/davsclaus
>>
>>
>
> --
> View this message in context: http://www.nabble.com/camel-routing---messages-stay-in-queue-tp25222552p25223111.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: camel routing - messages stay in queue

Posted by Markus Mueller <M....@dzbw.de>.
Unfortunately, I can't see how to do it in the 
    from A -> send to B
    from B -> send to C
way. 

My problem is, that the IN_BETWEEN_QUEUE is dynamic and depends on the
message. So my (a bit more more complex) configure looks like this : 

		from("activemq:queue:IN_QUEUE").process(new Processor() {

			public void process(Exchange exchange) throws Exception {

				Message inMessage = exchange.getIn();
				String routingInfo =
exchange.getIn().getBody().toString().substring(0,8);
				String targetSystem =
TargetResolver.getInstance().getSpecificRoute(routingInfo );
				Endpoint ep = getContext().getEndpoint("activemq:queue:" +
targetSystem);
				ProducerTemplate pt = getContext().createProducerTemplate();
				pt.send(ep, exchange);
			}

		});//.to("bean:resultBean");

My Problem is, that I don't know the real name of my IN_BETWEEN_QUEUE
outside my process(...). So if it doesn't work in the 
 from A -> send to B -> send to C
manner, I'll have to find another solution. But don't know how to right now.





Claus Ibsen-2 wrote:
> 
> On Mon, Aug 31, 2009 at 2:15 PM, Markus Mueller<M....@dzbw.de> wrote:
>>
>> I'm using camel 1.6 with servicemix 3.4.
>>
>> I've a simple route like this :
>> from("activemq:queue:IN_QUEUE").to("activemq:queue:IN_BETWEEN_QUEUE").to("bean:resultBean");
>>
>> So if I send a message to my IN_QUEUE it's routed to my IN_BETWEEN_QUEUE
>> and
>> also reaches my resultBean. That's what I excpected. The Problem is,
>> although the message is processed in my resultBean (without Exception) it
>> is
>> still in my IN_BETWEEN_QUEUE after all.
>>
>> If I delete the IN_BETWEEN_QUEUE and my route is like this :
>> from("activemq:queue:IN_QUEUE").to("bean:resultBean");
>> all is fine. The message is processed in my resultBean and after that
>> correctly disappears from my IN_QUEUE.
>>
>> I can't understand that. Can anyone help ?
> 
> Yeah what you are doing is like this
>      from A -> send to B -> send to C
> 
> What you want to do is
>     from A -> send to B
>     from B -> send to C
> 
> 
> And thus you should use 2 routes
> 
> from("activemq:queue:IN_QUEUE").to("activemq:queue:IN_BETWEEN_QUEUE");
> 
> from("activemq:queue:IN_BETWEEN_QUEUE").to("bean:resultBean");
> 
> 
> 
> 
>> Markus
>> --
>> View this message in context:
>> http://www.nabble.com/camel-routing---messages-stay-in-queue-tp25222552p25222552.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
> 
> 
> 
> -- 
> Claus Ibsen
> Apache Camel Committer
> 
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
> 
> 

-- 
View this message in context: http://www.nabble.com/camel-routing---messages-stay-in-queue-tp25222552p25223111.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: camel routing - messages stay in queue

Posted by Claus Ibsen <cl...@gmail.com>.
On Mon, Aug 31, 2009 at 2:15 PM, Markus Mueller<M....@dzbw.de> wrote:
>
> I'm using camel 1.6 with servicemix 3.4.
>
> I've a simple route like this :
> from("activemq:queue:IN_QUEUE").to("activemq:queue:IN_BETWEEN_QUEUE").to("bean:resultBean");
>
> So if I send a message to my IN_QUEUE it's routed to my IN_BETWEEN_QUEUE and
> also reaches my resultBean. That's what I excpected. The Problem is,
> although the message is processed in my resultBean (without Exception) it is
> still in my IN_BETWEEN_QUEUE after all.
>
> If I delete the IN_BETWEEN_QUEUE and my route is like this :
> from("activemq:queue:IN_QUEUE").to("bean:resultBean");
> all is fine. The message is processed in my resultBean and after that
> correctly disappears from my IN_QUEUE.
>
> I can't understand that. Can anyone help ?

Yeah what you are doing is like this
     from A -> send to B -> send to C

What you want to do is
    from A -> send to B
    from B -> send to C


And thus you should use 2 routes

from("activemq:queue:IN_QUEUE").to("activemq:queue:IN_BETWEEN_QUEUE");

from("activemq:queue:IN_BETWEEN_QUEUE").to("bean:resultBean");




> Markus
> --
> View this message in context: http://www.nabble.com/camel-routing---messages-stay-in-queue-tp25222552p25222552.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus