You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by apara <ap...@standardset.com> on 2013/09/02 04:06:49 UTC
How to pass properties between endpoints...
Before converting the event to JSON, I would like to store some variables
from the event and later use them in a to: destination.
So, am using header to stash away the values prior to conversion. Is this
the best way of doing this, or should I be using properties?
<camel:route>
...
<camel:setHeader headerName="userId">
<camel:simple
resultType="java.lang.Integer">${body.userId}</camel:simple>
</camel:setHeader>
<camel:setHeader headerName="eventName">
<camel:simple
resultType="java.lang.String">${body.class.simpleName}</camel:simple>
</camel:setHeader>
<camel:marshal>
<camel:json library="Jackson"/>
</camel:marshal>
<camel:convertBodyTo type="java.lang.String" />
<camel:to
uri="bean:drupalRestService?method=notifyEvent(${in.header.userId},
${in.header.eventName}, ${body})" />
</camel:route>
However, when I try to use the properties, I always a runtime exception
telling me that a PropertiesComponent needs to be defined inside of the
camel context. However, I am not sure how to create a properties component
inside of the camel context. I tried with just <properties/> but that did
not quite do the trick.
Any clues?
Thanks.
-AP_
--
View this message in context: http://camel.465427.n5.nabble.com/How-to-pass-properties-between-endpoints-tp5738449.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: How to pass properties between endpoints...
Posted by Claus Ibsen <cl...@gmail.com>.
There is 2 kind of properties with Camel
- properties on Exchange
- property placeholder
They are very different. You can find details on the Camel doc if you
search a bit and read.
On Mon, Sep 2, 2013 at 4:06 AM, apara <ap...@standardset.com> wrote:
> Before converting the event to JSON, I would like to store some variables
> from the event and later use them in a to: destination.
>
> So, am using header to stash away the values prior to conversion. Is this
> the best way of doing this, or should I be using properties?
>
> <camel:route>
> ...
>
> <camel:setHeader headerName="userId">
> <camel:simple
> resultType="java.lang.Integer">${body.userId}</camel:simple>
> </camel:setHeader>
>
> <camel:setHeader headerName="eventName">
> <camel:simple
> resultType="java.lang.String">${body.class.simpleName}</camel:simple>
> </camel:setHeader>
>
> <camel:marshal>
> <camel:json library="Jackson"/>
> </camel:marshal>
>
> <camel:convertBodyTo type="java.lang.String" />
>
> <camel:to
> uri="bean:drupalRestService?method=notifyEvent(${in.header.userId},
> ${in.header.eventName}, ${body})" />
>
> </camel:route>
>
> However, when I try to use the properties, I always a runtime exception
> telling me that a PropertiesComponent needs to be defined inside of the
> camel context. However, I am not sure how to create a properties component
> inside of the camel context. I tried with just <properties/> but that did
> not quite do the trick.
>
> Any clues?
>
> Thanks.
> -AP_
>
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/How-to-pass-properties-between-endpoints-tp5738449.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