FAQ
I'm having some problems getting this to work right, I'm hoping this is an
easy question.

The behavior I want is to check if the header contains a key, then do
something if that header key doesn't exist. I've tried several ways to
accomplish this, my current route that *doesn't accomplish my goal* is
below.

<route>
   <from uri="direct:input" />
   <choice>
    <when>
     <simple><notcontins>
      ${header.workflowId}
      </notcontins>
     </simple>
     <to uri="bean:com.acme.activator.ExampleProcessor"/>
    </when>
   </choice>
</route>

I'm new to Camel so any help would be greatly appreciated.

Thanks,
Shawn



--
View this message in context: http://camel.465427.n5.nabble.com/Make-decision-on-whether-header-key-exists-in-XML-DSL-tp5747585.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Search Discussions

  • Claus Ibsen at Feb 19, 2014 at 5:50 pm
    <when><header>someName</header>....</when>

    The <header> will just check if there is a header with that key.




    On Wed, Feb 19, 2014 at 6:44 PM, simholte wrote:
    I'm having some problems getting this to work right, I'm hoping this is an
    easy question.

    The behavior I want is to check if the header contains a key, then do
    something if that header key doesn't exist. I've tried several ways to
    accomplish this, my current route that *doesn't accomplish my goal* is
    below.

    <route>
    <from uri="direct:input" />
    <choice>
    <when>
    <simple><notcontins>
    ${header.workflowId}
    </notcontins>
    </simple>
    <to uri="bean:com.acme.activator.ExampleProcessor"/>
    </when>
    </choice>
    </route>

    I'm new to Camel so any help would be greatly appreciated.

    Thanks,
    Shawn



    --
    View this message in context: http://camel.465427.n5.nabble.com/Make-decision-on-whether-header-key-exists-in-XML-DSL-tp5747585.html
    Sent from the Camel - Users mailing list archive at Nabble.com.


    --
    Claus Ibsen
    -----------------
    Red Hat, Inc.
    Email: cibsen@redhat.com
    Twitter: davsclaus
    Blog: http://davsclaus.com
    Author of Camel in Action: http://www.manning.com/ibsen
    Make your Camel applications look hawt, try: http://hawt.io
  • Simholte at Feb 19, 2014 at 9:19 pm
    Thanks for the quick response!

    That works great, but I'm trying to make a decision on the absence of that
    key. I've added an otherwise block to make my solution work but I'm
    wondering if there's a better solution using a not or something?

    my new route:
    <route>
       <from uri="direct:input" />
       <choice>
        <when>
         <header>workflowId</header>
        </when>
        <otherwise>
         <to uri="bean:com.acme.activator.ExampleProcessor"/>
        </otherwise>
       </choice>
    </route>



    --
    View this message in context: http://camel.465427.n5.nabble.com/Make-decision-on-whether-header-key-exists-in-XML-DSL-tp5747585p5747599.html
    Sent from the Camel - Users mailing list archive at Nabble.com.
  • Claus Ibsen at Feb 20, 2014 at 6:46 am
    Ah

    Yeah then you cannot use <header>.

    You can use <simple>${header.workflowId} == null</simple> instead
    On Wed, Feb 19, 2014 at 10:18 PM, simholte wrote:
    Thanks for the quick response!

    That works great, but I'm trying to make a decision on the absence of that
    key. I've added an otherwise block to make my solution work but I'm
    wondering if there's a better solution using a not or something?

    my new route:
    <route>
    <from uri="direct:input" />
    <choice>
    <when>
    <header>workflowId</header>
    </when>
    <otherwise>
    <to uri="bean:com.acme.activator.ExampleProcessor"/>
    </otherwise>
    </choice>
    </route>



    --
    View this message in context: http://camel.465427.n5.nabble.com/Make-decision-on-whether-header-key-exists-in-XML-DSL-tp5747585p5747599.html
    Sent from the Camel - Users mailing list archive at Nabble.com.


    --
    Claus Ibsen
    -----------------
    Red Hat, Inc.
    Email: cibsen@redhat.com
    Twitter: davsclaus
    Blog: http://davsclaus.com
    Author of Camel in Action: http://www.manning.com/ibsen
    Make your Camel applications look hawt, try: http://hawt.io

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupusers @
categoriescamel
postedFeb 19, '14 at 5:45p
activeFeb 20, '14 at 6:46a
posts4
users2
websitecamel.apache.org

2 users in discussion

Claus Ibsen: 2 posts Simholte: 2 posts

People

Translate

site design / logo © 2022 Grokbase