Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache Camel - all headers are lost except String during routing to ActiveMQ

I am setting a List in exchange object's header with other couple of headers and routing it to ActiveMQ.

exchange.getOut().setHeader("testList", testList);
exchange.getOut().setHeader("testObject", testObject); 
exchange.getOut().setHeader("header1", "value1");  
exchange.getOut().setHeader("header2", "value2");

In the next route when I access the exchange object's header, "testList" and testObject are not present ! But remaining headers are present (exchange.getIn().getHeader).

Can't we send any header ( list or any other object) except String ?

like image 404
VGH Avatar asked Feb 07 '23 19:02

VGH


1 Answers

According to Camel documentation:

For the exchange.in.header, the following rules apply for the header values:

The values must be primitives or their counter objects (such as Integer, Long, Character). The types, String, CharSequence, Date, BigDecimal and BigInteger are all converted to their toString() representation. All other types are dropped.

More information can be found here: http://camel.apache.org/jms or here http://docs.oracle.com/javaee/1.4/api/javax/jms/Message.html

See Camel manual section : Message format when sending

Camel will remove headers not allowed types, but you can use vm or seda components instead of activemq. Or you can convert your list into XML or JSON, convert it to a string and send this string through JMS.

like image 197
Alexey Yakunin Avatar answered Mar 29 '23 23:03

Alexey Yakunin