You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Mike Reynolds <Mi...@yahoo.com> on 2010/05/20 05:06:25 UTC

how to route a single message to multiple MessageGroups?

I'm using Camel 2.2, ActiveMQ 5.3.
I'd like to route a single message to a number ActiveMQ MessageGroups (as
determined at runtime based on the message content).

Use Case:
1) message FOO comes in of type BAR
2) a db lookup is performed, and it is determined that all BAR messages must
be placed in both MessageGroup BAZ1 and MessageGroup BAZ2

In camel, how do I map this?  I was hoping to use "@RecipientList", but they
are all the same queue (I was hoping I could specify the JMSXGroupID in the
uri of the destination)  Is Loop the only way to go?

I'm building this with the Java DSL.

Thanks so much!
-- 
View this message in context: http://old.nabble.com/how-to-route-a-single-message-to-multiple-MessageGroups--tp28616669p28616669.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: how to route a single message to multiple MessageGroups?

Posted by Mike Reynolds <Mi...@yahoo.com>.


> Thanks, Claus.  I ended up using the loop DSL, and it looks like the
> messages are created properly on the queue with the proper JMSXGroupID
> header property.
> However, now when I attempt to process them, they are all being processed
> in a pipeline (serial).  And if I set it to async, the rules of
> MessageGroups don't seem to apply (i.e. multiple messages in MessageGroupA
> get processed simultaneously).
> 
> Here is my route:
> from("activemq:personnel.records_sink").
>                 loop(3).
>                 to("bean:pushModeProcessor").
>                 to("activemq:queue:pushModeAgentQueue").
>                 to("bean:pushEventToAgent");
> 
> activemq:personnel.records_sink is my source to start the process
> I have it looping three times (for testing)
> pushModeProcessor bean adds the appropriate header: 
> exchange.getIn().setHeader("JMSXGroupID", groupName);
> pushModeAgentQueue is the queue that holds the message
> pushEventToAgent bean simply waits for a time (depending on the groupName)
> and prints out a message.
> 
> Am I missing something obvious?
> On my console, I can see that the message in group 1 is processed (10
> seconds), and then message in group 2 (5 seconds), and then 1 (1 second). 
> I would expect to see group 1 start, group 2 start, group 3 start, group 3
> complete, group 2 complete, and finally group 1 complete.
> 

I figured out the issue.  I had to have to routes 
- the first would terminate after the loop/bean/push to queue.
- the second would start from the queue and call the pushEventToAgent bean.

What I was missing before was I set in the from queue uri (in the second
route) "?concurrentConsumers=5".

Everything is now working - thanks.

-- 
View this message in context: http://old.nabble.com/how-to-route-a-single-message-to-multiple-MessageGroups--tp28616669p28634679.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: how to route a single message to multiple MessageGroups?

Posted by Mike Reynolds <Mi...@yahoo.com>.
>You can send them one at a time and change the JMSXGroupID.
>Or you can use a bean to send the messages from java code using the
>ProducerTemplate to do that in one line of code.
>Then you can set/change the JMSXGroupID in Java code.

Thanks, Claus.  I ended up using the loop DSL, and it looks like the
messages are created properly on the queue with the proper JMSXGroupID
header property.
However, now when I attempt to process them, they are all being processed in
a pipeline (serial).  And if I set it to async, the rules of MessageGroups
don't seem to apply (i.e. multiple messages in MessageGroupA get processed
simultaneously).

Here is my route:
from("activemq:personnel.records_sink").
                loop(3).
                to("bean:pushModeProcessor").
                to("activemq:queue:pushModeAgentQueue").
                to("bean:pushEventToAgent");

activemq:personnel.records_sink is my source to start the process
I have it looping three times (for testing)
pushModeProcessor bean adds the appropriate header: 
exchange.getIn().setHeader("JMSXGroupID", groupName);
pushModeAgentQueue is the queue that holds the message
pushEventToAgent bean simply waits for a time (depending on the groupName)
and prints out a message.

Am I missing something obvious?
On my console, I can see that the message in group 1 is processed (10
seconds), and then message in group 2 (5 seconds), and then 1 (1 second).  I
would expect to see group 1 start, group 2 start, group 3 start, group 3
complete, group 2 complete, and finally group 1 complete.
-- 
View this message in context: http://old.nabble.com/how-to-route-a-single-message-to-multiple-MessageGroups--tp28616669p28629704.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: how to route a single message to multiple MessageGroups?

Posted by Claus Ibsen <cl...@gmail.com>.
On Thu, May 20, 2010 at 2:10 PM, Mike Reynolds <Mi...@yahoo.com> wrote:
>
> But how do I send it multiple recipients?
> I'd like to send the message to QueueA with JMSXGroupID=GROUPA and QueueA
> with JMSXGroupID=GROUPB
> So - basically multiple copies of the message to the same queue but with
> different JMSXGroupID's.
>

You can send them one at a time and change the JMSXGroupID.
Or you can use a bean to send the messages from java code using the
ProducerTemplate to do that in one line of code.
Then you can set/change the JMSXGroupID in Java code.



>
> Claus Ibsen-2 wrote:
>>
>> Hi
>>
>> Use the Content Based Router to route the message to either one.
>> And on the way you can set the header accordingly.
>>
>>
>>
>> On Thu, May 20, 2010 at 5:06 AM, Mike Reynolds <Mi...@yahoo.com>
>> wrote:
>>>
>>> I'm using Camel 2.2, ActiveMQ 5.3.
>>> I'd like to route a single message to a number ActiveMQ MessageGroups (as
>>> determined at runtime based on the message content).
>>>
>>> Use Case:
>>> 1) message FOO comes in of type BAR
>>> 2) a db lookup is performed, and it is determined that all BAR messages
>>> must
>>> be placed in both MessageGroup BAZ1 and MessageGroup BAZ2
>>>
>>> In camel, how do I map this?  I was hoping to use "@RecipientList", but
>>> they
>>> are all the same queue (I was hoping I could specify the JMSXGroupID in
>>> the
>>> uri of the destination)  Is Loop the only way to go?
>>>
>>> I'm building this with the Java DSL.
>>>
>>> Thanks so much!
>>> --
>>> View this message in context:
>>> http://old.nabble.com/how-to-route-a-single-message-to-multiple-MessageGroups--tp28616669p28616669.html
>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>>
>> --
>> Claus Ibsen
>> Apache Camel Committer
>>
>> Author of Camel in Action: http://www.manning.com/ibsen/
>> Open Source Integration: http://fusesource.com
>> Blog: http://davsclaus.blogspot.com/
>> Twitter: http://twitter.com/davsclaus
>>
>>
>
> --
> View this message in context: http://old.nabble.com/how-to-route-a-single-message-to-multiple-MessageGroups--tp28616669p28620314.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: how to route a single message to multiple MessageGroups?

Posted by Mike Reynolds <Mi...@yahoo.com>.
But how do I send it multiple recipients?
I'd like to send the message to QueueA with JMSXGroupID=GROUPA and QueueA
with JMSXGroupID=GROUPB
So - basically multiple copies of the message to the same queue but with
different JMSXGroupID's.


Claus Ibsen-2 wrote:
> 
> Hi
> 
> Use the Content Based Router to route the message to either one.
> And on the way you can set the header accordingly.
> 
> 
> 
> On Thu, May 20, 2010 at 5:06 AM, Mike Reynolds <Mi...@yahoo.com>
> wrote:
>>
>> I'm using Camel 2.2, ActiveMQ 5.3.
>> I'd like to route a single message to a number ActiveMQ MessageGroups (as
>> determined at runtime based on the message content).
>>
>> Use Case:
>> 1) message FOO comes in of type BAR
>> 2) a db lookup is performed, and it is determined that all BAR messages
>> must
>> be placed in both MessageGroup BAZ1 and MessageGroup BAZ2
>>
>> In camel, how do I map this?  I was hoping to use "@RecipientList", but
>> they
>> are all the same queue (I was hoping I could specify the JMSXGroupID in
>> the
>> uri of the destination)  Is Loop the only way to go?
>>
>> I'm building this with the Java DSL.
>>
>> Thanks so much!
>> --
>> View this message in context:
>> http://old.nabble.com/how-to-route-a-single-message-to-multiple-MessageGroups--tp28616669p28616669.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
> 
> 
> 
> -- 
> Claus Ibsen
> Apache Camel Committer
> 
> Author of Camel in Action: http://www.manning.com/ibsen/
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
> 
> 

-- 
View this message in context: http://old.nabble.com/how-to-route-a-single-message-to-multiple-MessageGroups--tp28616669p28620314.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: how to route a single message to multiple MessageGroups?

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

Use the Content Based Router to route the message to either one.
And on the way you can set the header accordingly.



On Thu, May 20, 2010 at 5:06 AM, Mike Reynolds <Mi...@yahoo.com> wrote:
>
> I'm using Camel 2.2, ActiveMQ 5.3.
> I'd like to route a single message to a number ActiveMQ MessageGroups (as
> determined at runtime based on the message content).
>
> Use Case:
> 1) message FOO comes in of type BAR
> 2) a db lookup is performed, and it is determined that all BAR messages must
> be placed in both MessageGroup BAZ1 and MessageGroup BAZ2
>
> In camel, how do I map this?  I was hoping to use "@RecipientList", but they
> are all the same queue (I was hoping I could specify the JMSXGroupID in the
> uri of the destination)  Is Loop the only way to go?
>
> I'm building this with the Java DSL.
>
> Thanks so much!
> --
> View this message in context: http://old.nabble.com/how-to-route-a-single-message-to-multiple-MessageGroups--tp28616669p28616669.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus