You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by john race <jo...@wwctrials.com> on 2012/06/26 14:35:10 UTC

spring xpath message router

Camel spring routing:

I'm trying to route a message depending on the content of an element. e.g.
for elements "aaaa_test1"/"aaaa_test2"/"bbbb_test"/"cccc_test" I want to say
- if the first 4 characters are "aaaa" route to queue 1, "bbbb" route to
queue 2, etc.

I know I can do a direct comparison (e.g. <xpath>/root/element =
'aaaa_test1'</xpath> ) but want to make it more flexible. Ideally I want to
acheive the following:

<choice>
    <when>
    <xpath>/root/element *LIKE *'aaaa'</xpath>
        <inOnly uri="activemq:queue1"/>
    </when>
    <xpath>/root/element *LIKE *'bbbb'</xpath>
        <inOnly uri="activemq:queue2"/>
    </when>
    <otherwise>
        <inOnly uri="activemq:queue3"/>
    </otherwise>
</choice>


Anyone know how to do this?

thanks.

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

Re: spring xpath message router

Posted by john race <jo...@wwctrials.com>.
Thanks Claus

I use java bean configuration for other parts of my routing - but for this
one I want to keep it all in the spring configuration if possible.

btw, the extract I posted was an extract from my Camel route context (ie
configured using spring).



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

Re: spring xpath message router

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

You can use the recipient list EIP, and from a java bean you can
combine this with @RecipientList
http://camel.apache.org/recipientlist-annotation.html

XPath is a complex language, and figuring out how to do like can take time.
But I think it has a sub string function etc.

If you wanna go down that path. Then I suggest using some xpath UI
tool where you can live enter xpath expressions
and see when you get it working.

I assume there may be some plugins for that to install in an IDE or the likes.




On Tue, Jun 26, 2012 at 2:35 PM, john race <jo...@wwctrials.com> wrote:
> Camel spring routing:
>
> I'm trying to route a message depending on the content of an element. e.g.
> for elements "aaaa_test1"/"aaaa_test2"/"bbbb_test"/"cccc_test" I want to say
> - if the first 4 characters are "aaaa" route to queue 1, "bbbb" route to
> queue 2, etc.
>
> I know I can do a direct comparison (e.g. <xpath>/root/element =
> 'aaaa_test1'</xpath> ) but want to make it more flexible. Ideally I want to
> acheive the following:
>
> <choice>
>    <when>
>    <xpath>/root/element *LIKE *'aaaa'</xpath>
>        <inOnly uri="activemq:queue1"/>
>    </when>
>    <xpath>/root/element *LIKE *'bbbb'</xpath>
>        <inOnly uri="activemq:queue2"/>
>    </when>
>    <otherwise>
>        <inOnly uri="activemq:queue3"/>
>    </otherwise>
> </choice>
>
>
> Anyone know how to do this?
>
> thanks.
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/spring-xpath-message-router-tp5715114.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen