camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: Camel message -How long custom headers and properties live
Date Mon, 05 Dec 2011 08:57:23 GMT
Hi

When you send messages with Camel, then only details from the
org.apache.camel.Message is being send over the protocols.
So for JMS that means, the Camel message body + headers.

The properties on the Exchange is *not* part of the message, and will
not be send. The properties is stored for the lifetime of the
Exchange, where Camel end users can use the properties to store and
get access to the data they stored at any time.

For JMS there is restrictions what you can send as headers, according
to the JMS spec. Take a read on the Camel JMS wiki page.

If the value type of a header is not valid according to the JMS spec,
then Camel will drop the header.
Generally simple types such as: boolean, int, String etc. works.



On Mon, Dec 5, 2011 at 1:25 AM, rspeter <rspeter@yahoo.com> wrote:
> Good day everyone,
>
> I am using apache-activemq-5.5.1-fuse-00-08 and camel-core-2.8.0-fuse-00-08
> and have read about few topics on how to solve the issue with custom headers
> and properties.
> But I am unable to solve this issue. Any help is appreciated.
>
> Earlier topic on this issue:
> http://camel.465427.n5.nabble.com/How-long-do-the-camel-headers-live-in-routes-td474477.html
> http://camel.465427.n5.nabble.com/Pass-properties-headers-to-another-endpoint-td477128.html
>
> All headers and properties are visible before the queue but they disappear
> once it reaches the JMS queue.
> The properties are worse than headers. I tried to log it after consuming
> from the queue and could see one or two headers.
>
> Sample test:
> ------------
>                <route inheritErrorHandler="true">
>                    <description>test1</description>
>                        <from uri="direct:test"/>
>                        <log message="before queue: properties"/>
>                        <log message="x1:${property.x1}"/>
>                        <log message="x2:${property.x2}"/>
>                        <log message="x3:${property.x3}"/>
>                        <log message="x4:${property.x4}"/>
>                        <doTry>
>
>                                <log message="swap properties to headers"/>
>                                <setHeader headerName="a1"><simple>${property.x1}</simple></setHeader>
>                                <setHeader headerName="b1"><simple>${property.x2}</simple></setHeader>
>                                <setHeader headerName="c1"><simple>${property.x3}</simple></setHeader>
>                                <setHeader headerName="d1"><simple>${property.x4}</simple></setHeader>
> <setHeader headerName="xyz"><constant>header as constant always
> works</constant></setHeader>
>                                <inOnly uri="activemq:myqueue1" inheritErrorHandler="true"/>
>                                <doCatch>
>                                        <exception>java.lang.Exception</exception>
>                                </doCatch>
>                        </doTry>
>                </route>
>
>
>                <route inheritErrorHandler="true">
>                        <description>test2</description>
>                   <from uri="activemq:myqueue1"/>
>                        <log message="after queue: properties"/>
>                        <log message="x1:${property.x1}"/>
>                        <log message="x2:${property.x2}"/>
>                        <log message="x3:${property.x3}"/>
>                        <log message="x4:${property.x4}"/>
>
>                        <log message="after queue: headers"/>
>                        <log message="a1:${in.header.a1}"/>
>                        <log message="b1:${in.header.b1}"/>
>                        <log message="c1:${in.header.c1}"/>
>                        <log message="d1:${in.header.d1}"/>
> <log message="xyz:${in.header.xyz}"/>
>
>
>                        <inOnly uri="activemq:myqueue2" inheritErrorHandler="true"/>
>        </route>
>
> The log results:
> --------------
>  INFO | before queue: properties
>  INFO | x1:test
>  INFO | x2:aaaa
>  INFO | x3:ffffff
>  INFO | x4:hello
>  INFO | swap properties to headers
>  INFO | after queue: properties
>  INFO | x1:
>  INFO | x2:
>  INFO | x3:
>  INFO | x4:
>  INFO | after queue: headers
>  INFO | a1:
>  INFO | b1:aaaa
>  INFO | c1:ffffff
>  INFO | d1:hello
> INFO | xyz:header as constant always works
>
> All properties are not visible, but some headers are visible except a1.
> Claus, Roman were suggesting to use property instead of headers, but I
> couldn't get it working.
> Could you please suggest?
>
> Regards
> Peter
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-message-How-long-custom-headers-and-properties-live-tp5047495p5047495.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.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Mime
View raw message