You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by "raheelhasanfsd ." <ra...@gmail.com> on 2013/12/20 16:03:24 UTC

Route message based on Tag Value - Apache Camel Spring

I am trying to learn Apache Camel Routes. For a basic example, I would like
to know how to route based on values in an XML tag. For example, if we have
3 xml files with parent tags:

<item type="n1" /><item type="n2" /><item type="n3" />


I want to route these 3 into 3 different pipes...

so here is my idea (in Spring):

<route id="NormalizeMessageData">
<from uri="jms:incomingOrders" /><convertBodyTo type="java.lang.String" />
<choice><when>
  <simple>${body} contains '?xml'</simple> <!-- to make sure its xml
file only -->
  *
  *
  *
  <unmarshal>
    <jaxb contextPath="org.fusesource.camel" />
  </unmarshal>
  <to uri="jms:orders" /></when></choice>


see the stars (*), this is where we need to put some checking. But how?


-- 
Regards,
Raheel Hasan

Re: Route message based on Tag Value - Apache Camel Spring

Posted by "kraythe ." <kr...@gmail.com>.
This page will probably help.

http://camel.apache.org/xpath.html


*Robert Simmons Jr. MSc. - Lead Java Architect @ EA*
*Author of: Hardcore Java (2003) and Maintainable Java (2012)*
*LinkedIn: **http://www.linkedin.com/pub/robert-simmons/40/852/a39
<http://www.linkedin.com/pub/robert-simmons/40/852/a39>*


On Fri, Dec 20, 2013 at 9:03 AM, raheelhasanfsd . <raheelhasan.fsd@gmail.com
> wrote:

> I am trying to learn Apache Camel Routes. For a basic example, I would like
> to know how to route based on values in an XML tag. For example, if we have
> 3 xml files with parent tags:
>
> <item type="n1" /><item type="n2" /><item type="n3" />
>
>
> I want to route these 3 into 3 different pipes...
>
> so here is my idea (in Spring):
>
> <route id="NormalizeMessageData">
> <from uri="jms:incomingOrders" /><convertBodyTo type="java.lang.String" />
> <choice><when>
>   <simple>${body} contains '?xml'</simple> <!-- to make sure its xml
> file only -->
>   *
>   *
>   *
>   <unmarshal>
>     <jaxb contextPath="org.fusesource.camel" />
>   </unmarshal>
>   <to uri="jms:orders" /></when></choice>
>
>
> see the stars (*), this is where we need to put some checking. But how?
>
>
> --
> Regards,
> Raheel Hasan
>