You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by luixv <lu...@gmail.com> on 2013/09/05 15:43:45 UTC

Camel message router

We are developing an application which uses active mqueue and apache camel as
router. This application is getting .html files as input (this files are NOT
xml compliant). Depending on the prefix of the filename I have to route the
file to different process. Actually the pattern "message router" <choice> /
<when> does what I am looking for. The problem is the switch works over an
xpath expression.

Then my question is: Is possible to access / apply the filename in a Xpath
expression? If yes then how? if not then how can I cope this problem?

Thanks!
v
Luix



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-message-router-tp5738769.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel message router

Posted by Raul Kripalani <ra...@evosent.com>.
You can use the in:header() XPath function provided by Camel to access an
IN message header.

For example:

contains(in:header('CamelFileName'), 'foo')

Or combine it with any other XPath function like starts-with, matches, etc.

The Camel XPath documentation page describes this function and others. And
it also explains how to enable Saxon if you need XPath 2.0 functions.

Regards,
Raúl.
On 5 Sep 2013 14:44, "luixv" <lu...@gmail.com> wrote:

> We are developing an application which uses active mqueue and apache camel
> as
> router. This application is getting .html files as input (this files are
> NOT
> xml compliant). Depending on the prefix of the filename I have to route the
> file to different process. Actually the pattern "message router" <choice> /
> <when> does what I am looking for. The problem is the switch works over an
> xpath expression.
>
> Then my question is: Is possible to access / apply the filename in a Xpath
> expression? If yes then how? if not then how can I cope this problem?
>
> Thanks!
> v
> Luix
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Camel-message-router-tp5738769.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Re: Camel message router

Posted by luixv <lu...@gmail.com>.
Thanks a lot.
It works!

Luis



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-message-router-tp5738769p5738835.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel message router

Posted by Christian Posta <ch...@gmail.com>.
give this a shot...

<choice>
  <when>
    <simple>${header.CamelFileName} regex '^prefix.*$'</simple>
    <continue...route...here/>
  </when>
</choice>


On Thu, Sep 5, 2013 at 8:58 AM, luixv <lu...@gmail.com> wrote:

> OK, thanks for your answer. How would you code this using spring xml?
>
> Luis
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Camel-message-router-tp5738769p5738789.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
*Christian Posta*
http://www.christianposta.com/blog
twitter: @christianposta

Re: Camel message router

Posted by luixv <lu...@gmail.com>.
OK, thanks for your answer. How would you code this using spring xml?

Luis 



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-message-router-tp5738769p5738789.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel message router

Posted by Christian Posta <ch...@gmail.com>.
Well, it doesn't have to be an xpath expression.
It can be any of the supported expression language options:
http://camel.apache.org/expression.html

For example, when processing files off the file system, the filename would
be added to the exchange message as a header, and you can do your
content-based routing off the header:

choice()

 .when(header("CamelFileName").startsWith("filePrefix")).....rest-of-route-here



On Thu, Sep 5, 2013 at 6:43 AM, luixv <lu...@gmail.com> wrote:

> We are developing an application which uses active mqueue and apache camel
> as
> router. This application is getting .html files as input (this files are
> NOT
> xml compliant). Depending on the prefix of the filename I have to route the
> file to different process. Actually the pattern "message router" <choice> /
> <when> does what I am looking for. The problem is the switch works over an
> xpath expression.
>
> Then my question is: Is possible to access / apply the filename in a Xpath
> expression? If yes then how? if not then how can I cope this problem?
>
> Thanks!
> v
> Luix
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Camel-message-router-tp5738769.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
*Christian Posta*
http://www.christianposta.com/blog
twitter: @christianposta