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 ?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With