camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Strachan" <james.strac...@gmail.com>
Subject Re: activeMQ - Camel integration example
Date Fri, 22 Aug 2008 08:48:30 GMT
2008/8/21 Andres Rangel <andresr@corp.moniker.com>:
> Hi,
>
> We are currently studying the possibility of using Camel for our jms
> project.
>
> I am a little bit confused.
>
> What we want is to have the Camel routing code in the same activeMQ
> instance.

Then either just add your routing rules to the activemq.xml - or drop
your Java and Spring code into the activemq/lib directory as a jar

> I ran the example that comes with ActiveMQ 5.1, where  all messages
> going to example.A get routed to example.B .
>
> I want to go further and be able to route based on conditions, to a
> dynamic queue (read from memory).
>
> So as you see I need to be able to "include" a java class to handle this
> routing.
>
> Problems so far:
>
> 1.       I have tried coding a class extending the RouteBuilder, but
> still is not clear how will I route to dynamic queue based on the
> content (I use body() right?)

To route to a different queue name using the payload of the message to
decide it you can either use a Content Based Router where you test for
different values...
http://activemq.apache.org/camel/content-based-router.html

or you can use an expression to determine the exact queue to send to
via a dynamic recipient list
http://activemq.apache.org/camel/recipient-list.html
e.g.

from("activemq:someQueue").recipientList().xpath("concat('activemq:Foo.',
/body/someValue");

which for a message

<body>
  <someValue>Cheese</someValue>
</body>

would be routed to the ActiveMQ queue "Foo.Cheese"



> 2.       How do I modify the activemq.xml file so that this class is
> registered and used for the routing?

either create your own classloader and use an embedded broker; write a
normal spring application and include the activemq.xml file - or jar
up your camel code and drop it into the standard ActiveMQ activemq/lib
directory


> 3.       Do I need to add the my class to a camel context or that wil be
> done automatically by ActiveMQ?

Yes - or you can use the <camelContext> <package>...</package> to
describe the packages to search for RouteBuilder classes

These links might help a bit
http://activemq.apache.org/camel/spring.html
http://activemq.apache.org/camel/spring-example.html
-- 
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://open.iona.com

Mime
View raw message