Quantcast

Camel message router

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Camel message router

luixv
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Camel message router

ceposta
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 <[hidden email]> 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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Camel message router

luixv
OK, thanks for your answer. How would you code this using spring xml?

Luis
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Camel message router

ceposta
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 <[hidden email]> 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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Camel message router

Raul Kripalani
In reply to this post by luixv
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" <[hidden email]> 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.
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Camel message router

luixv
In reply to this post by ceposta
Thanks a lot.
It works!

Luis
Loading...