You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by rspeter <rs...@yahoo.com> on 2011/12/05 01:25:27 UTC

Camel message -How long custom headers and properties live

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.

Re: Camel message -How long custom headers and properties live

Posted by Claus Ibsen <cl...@gmail.com>.
On Wed, Dec 7, 2011 at 11:26 PM, Christian Müller
<ch...@gmail.com> wrote:
> Hello Peter!
>
> I'm not sure, but may "//*/data/text()" doesn't return a String? It may
> return a kind of TextImpl (org.w3c.dom.Text) which isn't serializable and
> reason Camel drop it? Could you log the class of the header values?
>

Yes it will most likely return some internal DOM structure type. So by
using resultType="String" you tell Camel to convert that DOM structure
type to a plain String, which is an accepted type by JMS spec and thus
included.

You can use the Tracer to see what is going on
http://camel.apache.org/tracer

> Best,
> Christian
>
> On Tue, Dec 6, 2011 at 7:45 AM, rspeter <rs...@yahoo.com> wrote:
>
>> Hi Claus,
>>
>> As I said earlier, I am using only header now.
>> But I have issues tracking the header again.
>>
>> I used xpath to store value in a headerName='"test". I can see this header
>> is visible only when I explicitly set its result type to string, otherwise
>> the headername is not visible.
>>
>> Visible header:
>> <setHeader headerName="test"><xpath
>> resultType="java.lang.String">//*/data/text()</xpath></setHeader>
>>
>> NOT-Visible header:
>> <setHeader headerName="test"><xpath>//*/data/text()</xpath></setHeader>
>>
>> Thanks
>> Peter
>>
>> --
>> View this message in context:
>> http://camel.465427.n5.nabble.com/Camel-message-How-long-custom-headers-and-properties-live-tp5047495p5051169.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/

Re: Camel message -How long custom headers and properties live

Posted by Christian Müller <ch...@gmail.com>.
Hello Peter!

I'm not sure, but may "//*/data/text()" doesn't return a String? It may
return a kind of TextImpl (org.w3c.dom.Text) which isn't serializable and
reason Camel drop it? Could you log the class of the header values?

Best,
Christian

On Tue, Dec 6, 2011 at 7:45 AM, rspeter <rs...@yahoo.com> wrote:

> Hi Claus,
>
> As I said earlier, I am using only header now.
> But I have issues tracking the header again.
>
> I used xpath to store value in a headerName='"test". I can see this header
> is visible only when I explicitly set its result type to string, otherwise
> the headername is not visible.
>
> Visible header:
> <setHeader headerName="test"><xpath
> resultType="java.lang.String">//*/data/text()</xpath></setHeader>
>
> NOT-Visible header:
> <setHeader headerName="test"><xpath>//*/data/text()</xpath></setHeader>
>
> Thanks
> Peter
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Camel-message-How-long-custom-headers-and-properties-live-tp5047495p5051169.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Re: Camel message -How long custom headers and properties live

Posted by rspeter <rs...@yahoo.com>.
Hi Claus,

As I said earlier, I am using only header now.
But I have issues tracking the header again.

I used xpath to store value in a headerName='"test". I can see this header
is visible only when I explicitly set its result type to string, otherwise
the headername is not visible.

Visible header:
<setHeader headerName="test"><xpath
resultType="java.lang.String">//*/data/text()</xpath></setHeader>

NOT-Visible header:
<setHeader headerName="test"><xpath>//*/data/text()</xpath></setHeader>	

Thanks
Peter												 

--
View this message in context: http://camel.465427.n5.nabble.com/Camel-message-How-long-custom-headers-and-properties-live-tp5047495p5051169.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel message -How long custom headers and properties live

Posted by rspeter <rs...@yahoo.com>.
Hi Claus,

Thanks for the reply. 
I needed to keep track of the variable/values across queues, so I am using
headers now and not property.
but I did try what Christian was saying, but it ended up in stack trace.

Regards
Peter

--
View this message in context: http://camel.465427.n5.nabble.com/Camel-message-How-long-custom-headers-and-properties-live-tp5047495p5051058.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel message -How long custom headers and properties live

Posted by Claus Ibsen <cl...@gmail.com>.
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 <rs...@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/

Re: Camel message -How long custom headers and properties live

Posted by Christian Müller <ch...@gmail.com>.
Of course. It's what the WIKI says...
But I'm wondering why you receive an exception. It should "exclude any
non-serializable objects and log it at WARN level". Do you consider to
raise a JIRA if you receive an exception?

Best,
Christian

On Tue, Dec 6, 2011 at 6:38 AM, rspeter <rs...@yahoo.com> wrote:

> Hi Christian,
>
> The transferExchange options requires that the objects are serializable.
> I tried with the options below, but there were errors.
>
> <inOnly uri="activemq:myqueue1?transferExchange=true"
> > inheritErrorHandler="true"/>
>
>
> java.lang.RuntimeException: org.restlet.data.Parameter
>        at
>
> org.apache.activemq.command.ActiveMQObjectMessage.storeContent(ActiveMQObjectMessage.java:111)
>        at
>
> org.apache.activemq.command.ActiveMQObjectMessage.setObject(ActiveMQObjectMessage.java:162)
>        at
>
> org.apache.activemq.ActiveMQSession.createObjectMessage(ActiveMQSession.java:380)
>        at
>
> org.apache.camel.component.jms.JmsBinding.createJmsMessage(JmsBinding.java:416)
>        at
>
> org.apache.camel.component.jms.JmsBinding.makeJmsMessage(JmsBinding.java:267)
>        at
>
> org.apache.camel.component.jms.JmsProducer$2.createMessage(JmsProducer.java:225)
> ....................
>        at
>
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
>        at java.lang.Thread.run(Thread.java:662)
> Caused by: java.io.NotSerializableException: org.restlet.data.Parameter
>        at
> java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1164)
>        at
> java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1346)
>        at
> java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1154)
>        at
> java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:330)
>        at java.util.HashMap.writeObject(HashMap.java:1001)
>
> Regards
> Peter
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Camel-message-How-long-custom-headers-and-properties-live-tp5047495p5051051.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Re: Camel message -How long custom headers and properties live

Posted by rspeter <rs...@yahoo.com>.
Hi Christian,

The transferExchange options requires that the objects are serializable.
I tried with the options below, but there were errors.

<inOnly uri="activemq:myqueue1?transferExchange=true"
> inheritErrorHandler="true"/> 


java.lang.RuntimeException: org.restlet.data.Parameter
	at
org.apache.activemq.command.ActiveMQObjectMessage.storeContent(ActiveMQObjectMessage.java:111)
	at
org.apache.activemq.command.ActiveMQObjectMessage.setObject(ActiveMQObjectMessage.java:162)
	at
org.apache.activemq.ActiveMQSession.createObjectMessage(ActiveMQSession.java:380)
	at
org.apache.camel.component.jms.JmsBinding.createJmsMessage(JmsBinding.java:416)
	at
org.apache.camel.component.jms.JmsBinding.makeJmsMessage(JmsBinding.java:267)
	at
org.apache.camel.component.jms.JmsProducer$2.createMessage(JmsProducer.java:225)
....................
	at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
	at java.lang.Thread.run(Thread.java:662)
Caused by: java.io.NotSerializableException: org.restlet.data.Parameter
	at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1164)
	at java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1346)
	at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1154)
	at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:330)
	at java.util.HashMap.writeObject(HashMap.java:1001)

Regards
Peter

--
View this message in context: http://camel.465427.n5.nabble.com/Camel-message-How-long-custom-headers-and-properties-live-tp5047495p5051051.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel message -How long custom headers and properties live

Posted by Christian Müller <ch...@gmail.com>.
To transfer exchange properties in JMS you have to use the
"transferExchange" option [1].

[1] http://camel.apache.org/jms.html

Best,
Christian

On Mon, Dec 5, 2011 at 1:25 AM, rspeter <rs...@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.
>