Content Based Router Spring XML

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Content Based Router Spring XML

William Tam
The XML config example in the doc seems to be obsolete
http://activemq.apache.org/camel/content-based-router.html.  I am
trying to use the Simple language support.  Does "${in.header.foo} =
'bar'" look right?  I am trying to say "if in.header foo equals to
'bar'".  It does not seem to work.

Thanks,
William

 <route>
            <from uri="seda:a"/>
            <choice>
                <when>
                    <simple>${in.header.foo} = 'bar'</simple>
                    <to uri="seda:b"/>
                </when>

                <when>
                    <simple>${in.header.foo} = 'cheese'</simple>
               <to uri="seda:c"/>
                </when>

                <otherwise>
                    <to uri="seda:d"/>
                </otherwise>
            </choice>
        </route>
Reply | Threaded
Open this post in threaded view
|

Re: Content Based Router Spring XML

jstrachan
On 11/10/2007, William Tam <[hidden email]> wrote:
> The XML config example in the doc seems to be obsolete
> http://activemq.apache.org/camel/content-based-router.html.

Fancy editing that? :)

>   I am
> trying to use the Simple language support.  Does "${in.header.foo} =
> 'bar'" look right?  I am trying to say "if in.header foo equals to
> 'bar'".  It does not seem to work.

The simple language doesn't yet support predicates unfortunatey. I
recommend you use either EL,  XPath or Groovy

http://activemq.apache.org/camel/languages.html

XPath is a good choice as it doesn't add any new dependencies; you can
evaluate XPath from camel-core.

--
James
-------
http://macstrac.blogspot.com/

Open Source SOA
http://open.iona.com
Reply | Threaded
Open this post in threaded view
|

Re: Content Based Router Spring XML

William Tam
It changed to below using xpath and it worked (thanks!).  However, my
message body had to be a XML doc (even though my predicate was only
checking the header).  Is it a bug?

                <when>
                    <xpath>$foo = 'bar'</xpath>
                    <to uri="seda:b"/>
                </when>

                <when>
                    <xpath>$foo = 'cheese'</xpath>
               <to uri="seda:c"/>
                </when>


On 10/11/07, James Strachan <[hidden email]> wrote:

> On 11/10/2007, William Tam <[hidden email]> wrote:
> > The XML config example in the doc seems to be obsolete
> > http://activemq.apache.org/camel/content-based-router.html.
>
> Fancy editing that? :)
>
> >   I am
> > trying to use the Simple language support.  Does "${in.header.foo} =
> > 'bar'" look right?  I am trying to say "if in.header foo equals to
> > 'bar'".  It does not seem to work.
>
> The simple language doesn't yet support predicates unfortunatey. I
> recommend you use either EL,  XPath or Groovy
>
> http://activemq.apache.org/camel/languages.html
>
> XPath is a good choice as it doesn't add any new dependencies; you can
> evaluate XPath from camel-core.
>
> --
> James
> -------
> http://macstrac.blogspot.com/
>
> Open Source SOA
> http://open.iona.com
>
Reply | Threaded
Open this post in threaded view
|

Re: Content Based Router Spring XML

jstrachan
On 11/10/2007, William Tam <[hidden email]> wrote:
> It changed to below using xpath and it worked (thanks!).  However, my
> message body had to be a XML doc (even though my predicate was only
> checking the header).  Is it a bug?

Damn - forgot about that. Wonder if we can get around that (lazily
parsing the body as a document only if the XPath expression requires
it).

I guess EL or Groovy is safer then for header only stuff?

--
James
-------
http://macstrac.blogspot.com/

Open Source SOA
http://open.iona.com