You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by ilango_g <il...@yahoo.com> on 2008/10/13 22:24:53 UTC

how to implement Content-based router

Hi
I have the following scenario: There would be a queue that has messages
sitting on it. This queue has a listener that listens for messages and
routes a certain message to a different queue (channel). So the queue acts
as a Content-Based Router that examines the message content and routes the
message onto a different queue channel based on data contained in the
message. The routing can be based on the values carried in the JMS message.

Is there a sample available that implements this pattern?

thanks 
-- 
View this message in context: http://www.nabble.com/how-to-implement-Content-based-router-tp19962213p19962213.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: how to implement Content-based router

Posted by Bruce Snyder <br...@gmail.com>.
On Tue, Oct 14, 2008 at 5:45 PM, ilango_g <il...@yahoo.com> wrote:
>
> I would definitely want to try this one out. The other question I have is: is
> it possible to have an MDB or a servlet do the same job?
>
> If it is, where can I start?
> Meanwhile, I will start working on the content based router based on your
> suggestions.

Sure, Camel is just an API for enterprise integration patterns and
more on top of the Spring Framework. You can use the Camel API just
like any other Java API in any Java classes. Take a look at the
getting started page:

http://activemq.apache.org/camel/getting-started.html

And also at the walk through page:

http://activemq.apache.org/camel/walk-through-an-example.html

Just create a Java class and start using the Camel API.

Bruce
-- 
perl -e 'print unpack("u30","D0G)U8V4\@4VYY9&5R\"F)R=6-E+G-N>61E<D\!G;6%I;\"YC;VT*"
);'

Apache ActiveMQ - http://activemq.org/
Apache Camel - http://activemq.org/camel/
Apache ServiceMix - http://servicemix.org/

Blog: http://bruceblog.org/

Re: how to implement Content-based router

Posted by ilango_g <il...@yahoo.com>.
I would definitely want to try this one out. The other question I have is: is
it possible to have an MDB or a servlet do the same job? 

If it is, where can I start?
Meanwhile, I will start working on the content based router based on your
suggestions.

thanks
ilango

bsnyder wrote:
> 
> On Mon, Oct 13, 2008 at 4:52 PM, ilango_g <il...@yahoo.com> wrote:
>>
>> Actually I have refined my question further:
>> There would be a queue that has messages
>> sitting on it. This queue has a listener that listens for messages, picks
>> up
>> a certain message (FIFO perhaps), and sends it off to a different queue
>> (channel) based on some information in a header field that identifies the
>> destination queue the message is intended for. For now, I assume that I
>> have
>> one message in my source queue that is meant to be delivered to one of
>> three
>> queues, Q1, Q2, Q3, based on the information in the JMS header of the
>> message.
>>
>> If a sample is available that would be great to start off.
> 
> As I said, creating a content-based router using Apache Camel is the
> easiest way to achieve this task. Take a look at the default
> configuration for ActiveMQ in conf/activemq.xml and you'll see a very
> basic example of configuring a route using Camel to route messages
> from a queue named example.A to a queue named example.B. You can
> easily augment this simple example to add the necessary configuration
> to implement the content-based router as shown on the Camel page
> (http://activemq.apache.org/camel/content-based-router.html) under the
> heading 'Using the Spring XML Extensions'. Bear in mind that that is
> just one example as use of XPath is not required as Camel supports
> many different languages for use of expressions
> (http://activemq.apache.org/camel/languages.html).
> 
>  Bruce
> -- 
> perl -e 'print
> unpack("u30","D0G)U8V4\@4VYY9&5R\"F)R=6-E+G-N>61E<D\!G;6%I;\"YC;VT*"
> );'
> 
> Apache ActiveMQ - http://activemq.org/
> Apache Camel - http://activemq.org/camel/
> Apache ServiceMix - http://servicemix.org/
> 
> Blog: http://bruceblog.org/
> 
> 

-- 
View this message in context: http://www.nabble.com/how-to-implement-Content-based-router-tp19962213p19984802.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: how to implement Content-based router

Posted by Bruce Snyder <br...@gmail.com>.
On Mon, Oct 13, 2008 at 4:52 PM, ilango_g <il...@yahoo.com> wrote:
>
> Actually I have refined my question further:
> There would be a queue that has messages
> sitting on it. This queue has a listener that listens for messages, picks up
> a certain message (FIFO perhaps), and sends it off to a different queue
> (channel) based on some information in a header field that identifies the
> destination queue the message is intended for. For now, I assume that I have
> one message in my source queue that is meant to be delivered to one of three
> queues, Q1, Q2, Q3, based on the information in the JMS header of the
> message.
>
> If a sample is available that would be great to start off.

As I said, creating a content-based router using Apache Camel is the
easiest way to achieve this task. Take a look at the default
configuration for ActiveMQ in conf/activemq.xml and you'll see a very
basic example of configuring a route using Camel to route messages
from a queue named example.A to a queue named example.B. You can
easily augment this simple example to add the necessary configuration
to implement the content-based router as shown on the Camel page
(http://activemq.apache.org/camel/content-based-router.html) under the
heading 'Using the Spring XML Extensions'. Bear in mind that that is
just one example as use of XPath is not required as Camel supports
many different languages for use of expressions
(http://activemq.apache.org/camel/languages.html).

 Bruce
-- 
perl -e 'print unpack("u30","D0G)U8V4\@4VYY9&5R\"F)R=6-E+G-N>61E<D\!G;6%I;\"YC;VT*"
);'

Apache ActiveMQ - http://activemq.org/
Apache Camel - http://activemq.org/camel/
Apache ServiceMix - http://servicemix.org/

Blog: http://bruceblog.org/

Re: how to implement Content-based router

Posted by ilango_g <il...@yahoo.com>.
Actually I have refined my question further:
There would be a queue that has messages
sitting on it. This queue has a listener that listens for messages, picks up
a certain message (FIFO perhaps), and sends it off to a different queue
(channel) based on some information in a header field that identifies the
destination queue the message is intended for. For now, I assume that I have
one message in my source queue that is meant to be delivered to one of three
queues, Q1, Q2, Q3, based on the information in the JMS header of the
message.

If a sample is available that would be great to start off. 

thanks


bsnyder wrote:
> 
> On Mon, Oct 13, 2008 at 1:24 PM, ilango_g <il...@yahoo.com> wrote:
>>
>> Hi
>> I have the following scenario: There would be a queue that has messages
>> sitting on it. This queue has a listener that listens for messages and
>> routes a certain message to a different queue (channel). So the queue
>> acts
>> as a Content-Based Router that examines the message content and routes
>> the
>> message onto a different queue channel based on data contained in the
>> message. The routing can be based on the values carried in the JMS
>> message.
>>
>> Is there a sample available that implements this pattern?
> 
> The easiest way to do this is using Apache Camel. See the following
> for more info:
> 
> http://activemq.apache.org/camel/content-based-router.html
> 
> Bruce
> -- 
> perl -e 'print
> unpack("u30","D0G)U8V4\@4VYY9&5R\"F)R=6-E+G-N>61E<D\!G;6%I;\"YC;VT*"
> );'
> 
> Apache ActiveMQ - http://activemq.org/
> Apache Camel - http://activemq.org/camel/
> Apache ServiceMix - http://servicemix.org/
> 
> Blog: http://bruceblog.org/
> 
> 

-- 
View this message in context: http://www.nabble.com/how-to-implement-Content-based-router-tp19962213p19964954.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: how to implement Content-based router

Posted by Bruce Snyder <br...@gmail.com>.
On Mon, Oct 13, 2008 at 1:24 PM, ilango_g <il...@yahoo.com> wrote:
>
> Hi
> I have the following scenario: There would be a queue that has messages
> sitting on it. This queue has a listener that listens for messages and
> routes a certain message to a different queue (channel). So the queue acts
> as a Content-Based Router that examines the message content and routes the
> message onto a different queue channel based on data contained in the
> message. The routing can be based on the values carried in the JMS message.
>
> Is there a sample available that implements this pattern?

The easiest way to do this is using Apache Camel. See the following
for more info:

http://activemq.apache.org/camel/content-based-router.html

Bruce
-- 
perl -e 'print unpack("u30","D0G)U8V4\@4VYY9&5R\"F)R=6-E+G-N>61E<D\!G;6%I;\"YC;VT*"
);'

Apache ActiveMQ - http://activemq.org/
Apache Camel - http://activemq.org/camel/
Apache ServiceMix - http://servicemix.org/

Blog: http://bruceblog.org/