You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@activemq.apache.org by James Strachan <ja...@gmail.com> on 2007/03/19 19:04:33 UTC

[HeadsUp] Camel library for POJO based routing...

While hungover and stuck on a train I hacked up a little POJO library
I've wanted for a while - an easy way to route stuff around JMS using
a simple Java DSL and ultimately for easily creating Enterprise
Integration Patterns in pure Java...

http://cwiki.apache.org/CAMEL/routes.html
http://cwiki.apache.org/CAMEL/eip.html

its still very much work in progress though!  The basic idea is to use
Java rather than XML (shock horror!) for creating routing rules and to
use generics to make it easy to work with JMS messages directly or to
work with other kinds of message like HTTP, JBI or JAX-WS etc

I'm still tinkering with it to get the JMS stuff working nicely.  I've
kept the JMS stuff separate (in camel-jms) so that the camel-core.jar
has minimal dependencies so hopefully we might be able to reuse this
library on other projects like ServiceMix and CXF

Ultimately I'd like to make it easy to drop JMS routes on the
classpath which could be automatically embedded in the broker, or
enabled in any Spring XML file to simplify the JMS processing for end
users.

I'll post more details as things start to settle down...

As usual, feedback greatly appreciated!
-- 

James
-------
http://radio.weblogs.com/0112098/

Re: [HeadsUp] Camel library for POJO based routing...

Posted by James Strachan <ja...@gmail.com>.
BTW a quick request for some naming feedback :). Naming is definitely
the hardest bit of programming.

I went ahead and added a basic API in Exchange for headers and added
getters for the request, response, fault. In JBI they are called in,
out, fault. Any views on which folks prefer? request/response is kinda
servlety & maybe a little easier for folks to understand. Though maybe
in/out/fault is a bit more WSDLy? :)

I was thinking we should expose the payloads as an Object as well for
in/out/fault - I do also like CXF's idea of you ask for a payload and
specify a type you want to see it as to deal with conversions (e.g in
JBI this would work nicely to turn the XML into DOM / JAXB / SAX or
whatnot).

I guess the cleaner API is if we define our own minimal Message
interface to hold methods like accessing the payload but then also
allow endpoints to expose the real interfaces of those messages if
folks need them?


On 3/20/07, James Strachan <ja...@gmail.com> wrote:
> On 3/20/07, Guillaume Nodet <gn...@gmail.com> wrote:
> > Sounds good.
> > I will try to see how it fits with ServiceMix ...
> > There are a few problems that may need some changes.
> > For example, support for different MEPs: JBI defines strict
> > meps (InOnly, InOut, etc...) that need to be known when the
> > exchange is created, so I guess we will need an additional
> > parameter when creating the exchange to specify if we expect
> > a response or not ....
>
> Yeah, we might need to have a few different createExchange() methods
> on some endpoints (like JBI or CXF). One of the things I hoped was
> that we can have typesafe exchange and endpoints to totally expose the
> full features of the underlying bus. e.g. JbiExchange and JbiEndpoint
> should expose all of the JBI APIs; ditto for Http, CXF, JMS etc. For
> JBI in particular but also for CXF too; there's the added complexity
> of fitting in with the component/endpoint container & lifecycle model
> though am sure we can get that working given time
>
> Though I'm pretty confident though we'll find some gremlins along the
> way as we try use Camel in ServiceMix, CXF or Servlets :). The one
> thing in our favour though is the Exchange and Endpoint types are
> pretty vague and pluggable, so I'm sure we can come up with, say, a
> JBI specific exchange API which works great with JBI - then once we've
> got a few endpoints that support InOut/InOnly we can see if we can
> pull a bit more stuff back into the Camel core.
>
>
> > More feedback will follow ...
> >
> > On 3/19/07, James Strachan <ja...@gmail.com> wrote:
> > >
> > > While hungover and stuck on a train I hacked up a little POJO library
> > > I've wanted for a while - an easy way to route stuff around JMS using
> > > a simple Java DSL and ultimately for easily creating Enterprise
> > > Integration Patterns in pure Java...
> > >
> > > http://cwiki.apache.org/CAMEL/routes.html
> > > http://cwiki.apache.org/CAMEL/eip.html
> > >
> > > its still very much work in progress though!  The basic idea is to use
> > > Java rather than XML (shock horror!) for creating routing rules and to
> > > use generics to make it easy to work with JMS messages directly or to
> > > work with other kinds of message like HTTP, JBI or JAX-WS etc
> > >
> > > I'm still tinkering with it to get the JMS stuff working nicely.  I've
> > > kept the JMS stuff separate (in camel-jms) so that the camel-core.jar
> > > has minimal dependencies so hopefully we might be able to reuse this
> > > library on other projects like ServiceMix and CXF
> > >
> > > Ultimately I'd like to make it easy to drop JMS routes on the
> > > classpath which could be automatically embedded in the broker, or
> > > enabled in any Spring XML file to simplify the JMS processing for end
> > > users.
> > >
> > > I'll post more details as things start to settle down...
> > >
> > > As usual, feedback greatly appreciated!
> > > --
> > >
> > > James
> > > -------
> > > http://radio.weblogs.com/0112098/
> > >
> >
> >
> >
> > --
> > Cheers,
> > Guillaume Nodet
> > ------------------------
> > Architect, LogicBlaze (http://www.logicblaze.com/)
> > Blog: http://gnodet.blogspot.com/
> >
>
>
> --
>
> James
> -------
> http://radio.weblogs.com/0112098/
>


-- 

James
-------
http://radio.weblogs.com/0112098/

Re: [HeadsUp] Camel library for POJO based routing...

Posted by James Strachan <ja...@gmail.com>.
On 3/20/07, Guillaume Nodet <gn...@gmail.com> wrote:
> Sounds good.
> I will try to see how it fits with ServiceMix ...
> There are a few problems that may need some changes.
> For example, support for different MEPs: JBI defines strict
> meps (InOnly, InOut, etc...) that need to be known when the
> exchange is created, so I guess we will need an additional
> parameter when creating the exchange to specify if we expect
> a response or not ....

Yeah, we might need to have a few different createExchange() methods
on some endpoints (like JBI or CXF). One of the things I hoped was
that we can have typesafe exchange and endpoints to totally expose the
full features of the underlying bus. e.g. JbiExchange and JbiEndpoint
should expose all of the JBI APIs; ditto for Http, CXF, JMS etc. For
JBI in particular but also for CXF too; there's the added complexity
of fitting in with the component/endpoint container & lifecycle model
though am sure we can get that working given time

Though I'm pretty confident though we'll find some gremlins along the
way as we try use Camel in ServiceMix, CXF or Servlets :). The one
thing in our favour though is the Exchange and Endpoint types are
pretty vague and pluggable, so I'm sure we can come up with, say, a
JBI specific exchange API which works great with JBI - then once we've
got a few endpoints that support InOut/InOnly we can see if we can
pull a bit more stuff back into the Camel core.


> More feedback will follow ...
>
> On 3/19/07, James Strachan <ja...@gmail.com> wrote:
> >
> > While hungover and stuck on a train I hacked up a little POJO library
> > I've wanted for a while - an easy way to route stuff around JMS using
> > a simple Java DSL and ultimately for easily creating Enterprise
> > Integration Patterns in pure Java...
> >
> > http://cwiki.apache.org/CAMEL/routes.html
> > http://cwiki.apache.org/CAMEL/eip.html
> >
> > its still very much work in progress though!  The basic idea is to use
> > Java rather than XML (shock horror!) for creating routing rules and to
> > use generics to make it easy to work with JMS messages directly or to
> > work with other kinds of message like HTTP, JBI or JAX-WS etc
> >
> > I'm still tinkering with it to get the JMS stuff working nicely.  I've
> > kept the JMS stuff separate (in camel-jms) so that the camel-core.jar
> > has minimal dependencies so hopefully we might be able to reuse this
> > library on other projects like ServiceMix and CXF
> >
> > Ultimately I'd like to make it easy to drop JMS routes on the
> > classpath which could be automatically embedded in the broker, or
> > enabled in any Spring XML file to simplify the JMS processing for end
> > users.
> >
> > I'll post more details as things start to settle down...
> >
> > As usual, feedback greatly appreciated!
> > --
> >
> > James
> > -------
> > http://radio.weblogs.com/0112098/
> >
>
>
>
> --
> Cheers,
> Guillaume Nodet
> ------------------------
> Architect, LogicBlaze (http://www.logicblaze.com/)
> Blog: http://gnodet.blogspot.com/
>


-- 

James
-------
http://radio.weblogs.com/0112098/

Re: [HeadsUp] Camel library for POJO based routing...

Posted by Guillaume Nodet <gn...@gmail.com>.
Sounds good.
I will try to see how it fits with ServiceMix ...
There are a few problems that may need some changes.
For example, support for different MEPs: JBI defines strict
meps (InOnly, InOut, etc...) that need to be known when the
exchange is created, so I guess we will need an additional
parameter when creating the exchange to specify if we expect
a response or not ....
More feedback will follow ...

On 3/19/07, James Strachan <ja...@gmail.com> wrote:
>
> While hungover and stuck on a train I hacked up a little POJO library
> I've wanted for a while - an easy way to route stuff around JMS using
> a simple Java DSL and ultimately for easily creating Enterprise
> Integration Patterns in pure Java...
>
> http://cwiki.apache.org/CAMEL/routes.html
> http://cwiki.apache.org/CAMEL/eip.html
>
> its still very much work in progress though!  The basic idea is to use
> Java rather than XML (shock horror!) for creating routing rules and to
> use generics to make it easy to work with JMS messages directly or to
> work with other kinds of message like HTTP, JBI or JAX-WS etc
>
> I'm still tinkering with it to get the JMS stuff working nicely.  I've
> kept the JMS stuff separate (in camel-jms) so that the camel-core.jar
> has minimal dependencies so hopefully we might be able to reuse this
> library on other projects like ServiceMix and CXF
>
> Ultimately I'd like to make it easy to drop JMS routes on the
> classpath which could be automatically embedded in the broker, or
> enabled in any Spring XML file to simplify the JMS processing for end
> users.
>
> I'll post more details as things start to settle down...
>
> As usual, feedback greatly appreciated!
> --
>
> James
> -------
> http://radio.weblogs.com/0112098/
>



-- 
Cheers,
Guillaume Nodet
------------------------
Architect, LogicBlaze (http://www.logicblaze.com/)
Blog: http://gnodet.blogspot.com/

Re: [HeadsUp] Camel library for POJO based routing...

Posted by James Strachan <ja...@gmail.com>.
On 3/20/07, Rob Davies <ra...@gmail.com> wrote:
> great work! I'm impressed by how much has already been done!
>
> btw - I'm considering putting a unique id on the exchange to support
> message store and message history patterns


There's also duplicate detection too
http://www.enterpriseintegrationpatterns.com/IdempotentReceiver.html


> but this would introduce a
> problem - where does the unique id come from ?
> I guess we have some options:
>
> 1. the endpoint generates it and sets it on the exchange
> 2. the endpoint asks the container for an id and then sets on the
> exchange
> 3. we return a proxy from the container for the Processor(s) - which
> automatically adds on an id and decorates the Exchange with any other
> stuff which might be useful
> 4. the contract is changed - so the exchange is passed through the
> container first - the container routes to the processor(s).
>
> Being a traditionalist (crusty ;))- I like the last option but are
> there other options which might ride the camel better ;) ?

Allowing an Expression<E> object to be configured would do the trick;
then some value inside the message (e.g. customerID or orderID) could
be used if need be.

Also I guess we could have a getMessageID() property on the exchange
or endpoint for times when there is one

-- 

James
-------
http://radio.weblogs.com/0112098/

Re: [HeadsUp] Camel library for POJO based routing...

Posted by rajdavies <ra...@gmail.com>.
Actually, scrub option 4 - I wouldn't like to loose the current contract


rajdavies wrote:
> 
> great work! I'm impressed by how much has already been done!
> 
> btw - I'm considering putting a unique id on the exchange to support  
> message store and message history patterns but this would introduce a  
> problem - where does the unique id come from ?
> I guess we have some options:
> 
> 1. the endpoint generates it and sets it on the exchange
> 2. the endpoint asks the container for an id and then sets on the  
> exchange
> 3. we return a proxy from the container for the Processor(s) - which  
> automatically adds on an id and decorates the Exchange with any other  
> stuff which might be useful
> 4. the contract is changed - so the exchange is passed through the  
> container first - the container routes to the processor(s).
> 
> Being a traditionalist (crusty ;))- I like the last option but are  
> there other options which might ride the camel better ;) ?
> 
> cheers,
> 
> Rob
> 
> On 20 Mar 2007, at 02:07, James Strachan wrote:
> 
>> On 3/19/07, James Strachan <ja...@gmail.com> wrote:
>>> While hungover and stuck on a train I hacked up a little POJO library
>>> I've wanted for a while - an easy way to route stuff around JMS using
>>> a simple Java DSL and ultimately for easily creating Enterprise
>>> Integration Patterns in pure Java...
>>>
>>> http://cwiki.apache.org/CAMEL/routes.html
>>> http://cwiki.apache.org/CAMEL/eip.html
>>>
>>> its still very much work in progress though!  The basic idea is to  
>>> use
>>> Java rather than XML (shock horror!) for creating routing rules  
>>> and to
>>> use generics to make it easy to work with JMS messages directly or to
>>> work with other kinds of message like HTTP, JBI or JAX-WS etc
>>>
>>> I'm still tinkering with it to get the JMS stuff working nicely.   
>>> I've
>>> kept the JMS stuff separate (in camel-jms) so that the camel-core.jar
>>> has minimal dependencies so hopefully we might be able to reuse this
>>> library on other projects like ServiceMix and CXF
>>>
>>> Ultimately I'd like to make it easy to drop JMS routes on the
>>> classpath which could be automatically embedded in the broker, or
>>> enabled in any Spring XML file to simplify the JMS processing for end
>>> users.
>>>
>>> I'll post more details as things start to settle down...
>>>
>>> As usual, feedback greatly appreciated!
>>
>> I've just managed to get the first JMS test case working :)
>>
>> https://svn.apache.org/repos/asf/activemq/camel/trunk/camel-jms/src/ 
>> test/java/org/apache/camel/jms/JmsRouteTest.java
>>
>> which under the covers uses Spring's JmsTemplate for sending and the
>> AbstractMessageListenerContainer stuff.
>> -- 
>>
>> James
>> -------
>> http://radio.weblogs.com/0112098/
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/-HeadsUp--Camel-library-for-POJO-based-routing...-tf3428742s2354.html#a9567730
Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.


Re: [HeadsUp] Camel library for POJO based routing...

Posted by Rob Davies <ra...@gmail.com>.
great work! I'm impressed by how much has already been done!

btw - I'm considering putting a unique id on the exchange to support  
message store and message history patterns but this would introduce a  
problem - where does the unique id come from ?
I guess we have some options:

1. the endpoint generates it and sets it on the exchange
2. the endpoint asks the container for an id and then sets on the  
exchange
3. we return a proxy from the container for the Processor(s) - which  
automatically adds on an id and decorates the Exchange with any other  
stuff which might be useful
4. the contract is changed - so the exchange is passed through the  
container first - the container routes to the processor(s).

Being a traditionalist (crusty ;))- I like the last option but are  
there other options which might ride the camel better ;) ?

cheers,

Rob

On 20 Mar 2007, at 02:07, James Strachan wrote:

> On 3/19/07, James Strachan <ja...@gmail.com> wrote:
>> While hungover and stuck on a train I hacked up a little POJO library
>> I've wanted for a while - an easy way to route stuff around JMS using
>> a simple Java DSL and ultimately for easily creating Enterprise
>> Integration Patterns in pure Java...
>>
>> http://cwiki.apache.org/CAMEL/routes.html
>> http://cwiki.apache.org/CAMEL/eip.html
>>
>> its still very much work in progress though!  The basic idea is to  
>> use
>> Java rather than XML (shock horror!) for creating routing rules  
>> and to
>> use generics to make it easy to work with JMS messages directly or to
>> work with other kinds of message like HTTP, JBI or JAX-WS etc
>>
>> I'm still tinkering with it to get the JMS stuff working nicely.   
>> I've
>> kept the JMS stuff separate (in camel-jms) so that the camel-core.jar
>> has minimal dependencies so hopefully we might be able to reuse this
>> library on other projects like ServiceMix and CXF
>>
>> Ultimately I'd like to make it easy to drop JMS routes on the
>> classpath which could be automatically embedded in the broker, or
>> enabled in any Spring XML file to simplify the JMS processing for end
>> users.
>>
>> I'll post more details as things start to settle down...
>>
>> As usual, feedback greatly appreciated!
>
> I've just managed to get the first JMS test case working :)
>
> https://svn.apache.org/repos/asf/activemq/camel/trunk/camel-jms/src/ 
> test/java/org/apache/camel/jms/JmsRouteTest.java
>
> which under the covers uses Spring's JmsTemplate for sending and the
> AbstractMessageListenerContainer stuff.
> -- 
>
> James
> -------
> http://radio.weblogs.com/0112098/


Re: [HeadsUp] Camel library for POJO based routing...

Posted by James Strachan <ja...@gmail.com>.
On 3/19/07, James Strachan <ja...@gmail.com> wrote:
> While hungover and stuck on a train I hacked up a little POJO library
> I've wanted for a while - an easy way to route stuff around JMS using
> a simple Java DSL and ultimately for easily creating Enterprise
> Integration Patterns in pure Java...
>
> http://cwiki.apache.org/CAMEL/routes.html
> http://cwiki.apache.org/CAMEL/eip.html
>
> its still very much work in progress though!  The basic idea is to use
> Java rather than XML (shock horror!) for creating routing rules and to
> use generics to make it easy to work with JMS messages directly or to
> work with other kinds of message like HTTP, JBI or JAX-WS etc
>
> I'm still tinkering with it to get the JMS stuff working nicely.  I've
> kept the JMS stuff separate (in camel-jms) so that the camel-core.jar
> has minimal dependencies so hopefully we might be able to reuse this
> library on other projects like ServiceMix and CXF
>
> Ultimately I'd like to make it easy to drop JMS routes on the
> classpath which could be automatically embedded in the broker, or
> enabled in any Spring XML file to simplify the JMS processing for end
> users.
>
> I'll post more details as things start to settle down...
>
> As usual, feedback greatly appreciated!

I've just managed to get the first JMS test case working :)

https://svn.apache.org/repos/asf/activemq/camel/trunk/camel-jms/src/test/java/org/apache/camel/jms/JmsRouteTest.java

which under the covers uses Spring's JmsTemplate for sending and the
AbstractMessageListenerContainer stuff.
-- 

James
-------
http://radio.weblogs.com/0112098/