You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Drone42 <ge...@logica.com> on 2010/01/14 16:03:50 UTC
Using the splitter based on POJO class type
I would like a route where I receive a message (rawframe), process it and
split it into multiple new message (different types; Frame, Packet,
Parameter), and thereafter route these to different endpoints.
Something like;
<route>
<from uri="activemq:topic:rawframe" />
<to uri="bean:marshaller" />
<choice>
<when>
<xpath>$class.type = 'frame'</xpath>
<to uri="activemq:topic:Frame"/>
</when>
<when>
<xpath>$class.type = 'packet'</xpath>
<to uri="activemq:topic:Packet"/>
</when>
<otherwise>
<xpath>$class.type = 'parameter'</xpath>
<to uri="activemq:topic:Parameter"/>
</otherwise>
</choice>
</route>
My questions are;
- Can a processor in a route split one input message into multiple messages
like this?
- How can I route the output messages from my processor based on the class
type? In the example I wrote '$class.type' as pseudo code.
Thanks,
Villemos.
--
View this message in context: http://old.nabble.com/Using-the-splitter-based-on-POJO-class-type-tp27162674p27162674.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Using the splitter based on POJO class type
Posted by Claus Ibsen <cl...@gmail.com>.
On Thu, Jan 14, 2010 at 5:42 PM, Drone42 <ge...@logica.com> wrote:
>
> Thanks for the very useful pointers. One questions;
>
> In the documentation of the splitter I only see how to build the route with
> a customer splitter using the fluent builder. Can I also configure this
> using spring XML, i.e. provide my splitter bean in the XML configuration of
> the route? And is the syntax described anywhere?
>
Yeah you can define a spring bean <bean id="foo" class=..."/> and then
have a <split><method ref="foo"
method="splitSomething"/>xxxxxx</split>
I cant recall the exact syntax.
Yeah the DZone refcard should have both java + xml examples. You can
find a link to it from here
http://camel.apache.org/articles.html
Otherwise the camel-spring component has plenty of unit tests :)
> Villemos.
>
>
>
>
>
> Claus Ibsen-2 wrote:
>>
>> Hi
>>
>>
>> On Thu, Jan 14, 2010 at 4:03 PM, Drone42 <ge...@logica.com> wrote:
>>>
>>> I would like a route where I receive a message (rawframe), process it and
>>> split it into multiple new message (different types; Frame, Packet,
>>> Parameter), and thereafter route these to different endpoints.
>>>
>>> Something like;
>>>
>>> <route>
>>> <from uri="activemq:topic:rawframe" />
>>> <to uri="bean:marshaller" />
>>> <choice>
>>> <when>
>>> <xpath>$class.type = 'frame'</xpath>
>>> <to uri="activemq:topic:Frame"/>
>>> </when>
>>> <when>
>>> <xpath>$class.type = 'packet'</xpath>
>>> <to uri="activemq:topic:Packet"/>
>>> </when>
>>> <otherwise>
>>> <xpath>$class.type = 'parameter'</xpath>
>>> <to uri="activemq:topic:Parameter"/>
>>> </otherwise>
>>> </choice>
>>> </route>
>>>
>>> My questions are;
>>> - Can a processor in a route split one input message into multiple
>>> messages
>>> like this?
>>
>> Check out using a POJO for splitter at
>> http://camel.apache.org/splitter.html
>>
>>> - How can I route the output messages from my processor based on the
>>> class
>>> type? In the example I wrote '$class.type' as pseudo code.
>>>
>>
>> See about xpath here
>> http://camel.apache.org/xpath
>>
>> I assume class type is something in the XML document
>> <class><type>foo</type></class> etc.
>>
>>
>>
>>> Thanks,
>>> Villemos.
>>> --
>>> View this message in context:
>>> http://old.nabble.com/Using-the-splitter-based-on-POJO-class-type-tp27162674p27162674.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/Using-the-splitter-based-on-POJO-class-type-tp27162674p27164293.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: Using the splitter based on POJO class type
Posted by Drone42 <ge...@logica.com>.
Thanks for the very useful pointers. One questions;
In the documentation of the splitter I only see how to build the route with
a customer splitter using the fluent builder. Can I also configure this
using spring XML, i.e. provide my splitter bean in the XML configuration of
the route? And is the syntax described anywhere?
Villemos.
Claus Ibsen-2 wrote:
>
> Hi
>
>
> On Thu, Jan 14, 2010 at 4:03 PM, Drone42 <ge...@logica.com> wrote:
>>
>> I would like a route where I receive a message (rawframe), process it and
>> split it into multiple new message (different types; Frame, Packet,
>> Parameter), and thereafter route these to different endpoints.
>>
>> Something like;
>>
>> <route>
>> <from uri="activemq:topic:rawframe" />
>> <to uri="bean:marshaller" />
>> <choice>
>> <when>
>> <xpath>$class.type = 'frame'</xpath>
>> <to uri="activemq:topic:Frame"/>
>> </when>
>> <when>
>> <xpath>$class.type = 'packet'</xpath>
>> <to uri="activemq:topic:Packet"/>
>> </when>
>> <otherwise>
>> <xpath>$class.type = 'parameter'</xpath>
>> <to uri="activemq:topic:Parameter"/>
>> </otherwise>
>> </choice>
>> </route>
>>
>> My questions are;
>> - Can a processor in a route split one input message into multiple
>> messages
>> like this?
>
> Check out using a POJO for splitter at
> http://camel.apache.org/splitter.html
>
>> - How can I route the output messages from my processor based on the
>> class
>> type? In the example I wrote '$class.type' as pseudo code.
>>
>
> See about xpath here
> http://camel.apache.org/xpath
>
> I assume class type is something in the XML document
> <class><type>foo</type></class> etc.
>
>
>
>> Thanks,
>> Villemos.
>> --
>> View this message in context:
>> http://old.nabble.com/Using-the-splitter-based-on-POJO-class-type-tp27162674p27162674.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/Using-the-splitter-based-on-POJO-class-type-tp27162674p27164293.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Using the splitter based on POJO class type
Posted by Claus Ibsen <cl...@gmail.com>.
Hi
On Thu, Jan 14, 2010 at 4:03 PM, Drone42 <ge...@logica.com> wrote:
>
> I would like a route where I receive a message (rawframe), process it and
> split it into multiple new message (different types; Frame, Packet,
> Parameter), and thereafter route these to different endpoints.
>
> Something like;
>
> <route>
> <from uri="activemq:topic:rawframe" />
> <to uri="bean:marshaller" />
> <choice>
> <when>
> <xpath>$class.type = 'frame'</xpath>
> <to uri="activemq:topic:Frame"/>
> </when>
> <when>
> <xpath>$class.type = 'packet'</xpath>
> <to uri="activemq:topic:Packet"/>
> </when>
> <otherwise>
> <xpath>$class.type = 'parameter'</xpath>
> <to uri="activemq:topic:Parameter"/>
> </otherwise>
> </choice>
> </route>
>
> My questions are;
> - Can a processor in a route split one input message into multiple messages
> like this?
Check out using a POJO for splitter at
http://camel.apache.org/splitter.html
> - How can I route the output messages from my processor based on the class
> type? In the example I wrote '$class.type' as pseudo code.
>
See about xpath here
http://camel.apache.org/xpath
I assume class type is something in the XML document
<class><type>foo</type></class> etc.
> Thanks,
> Villemos.
> --
> View this message in context: http://old.nabble.com/Using-the-splitter-based-on-POJO-class-type-tp27162674p27162674.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