camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrea Cosentino <>
Subject Re: Serializable headers lost by JmsBinding
Date Mon, 02 Jan 2017 09:15:00 GMT
This is related to this

Andrea Cosentino 
Apache Camel PMC Member
Apache Karaf Committer
Apache Servicemix Committer
Twitter: @oscerd2
Github: oscerd

On Monday, January 2, 2017 9:44 AM, barbara.devid <> wrote:
I search for this topic but could not find anything, so if it is a duplicate
I'm sorry.

In Apache Camel 2.0.15 I was able to set serializable objects in message
headers and send them through activemq queues without loose them.
In order to obtain this I had to set the "transferExchange=true" option on
both producer and consumer. Also I put the JVM options

Now I migrate to Apache Camel 2.0.17 and all my serializable headers are

I debugged the code and notice that:

the class org.apache.camel.component.jms.JmsBinding in camel-jms has not
change its behavior, but a class in camel-core did!

The class is org.apache.camel.impl.DefaultExchangeHolder .

In Camel 2.0.15 it had two marshal methods, 
static DefaultExchangeHolder     marshal(Exchange exchange)
static DefaultExchangeHolder     marshal(Exchange exchange, boolean

the first one just invoke the second one setting "includeProperties=true"

Now, in 2.0.17, the marshal methods are 3. Besides the old ones there is
this new method

static DefaultExchangeHolder     marshal(Exchange exchange, boolean
includeProperties, boolean allowSerializedHeaders)

The problem seems to be that marshal(Exchange exchange) now calls this new
method setting "allowedSerializedHeaders=false" .
Also the marshal(Exchange exchange, boolean includeProperties) invoke the
methods "safeSetInHeaders" and "safeSetOutHeaders" setting the
allowSerializeHeaders parameter to false.

Can you please tell me if in newer version of Apache Camel the code has
changed to fix this problem?
I cannot try it out, but maybe the camel-jms class JmsBinding should be
changed to call the 3 parameter marshal method this way:

protected Message *createJmsMessage*(Exchange exchange, Object body,
Map<String, Object> headers, Session session, CamelContext context) throws
JMSException {
        if(this.endpoint != null && *this.endpoint.isTransferExchange()*) {
            LOG.trace("Option transferExchange=true so we use
JmsMessageType: Object");
            DefaultExchangeHolder answer2 =
DefaultExchangeHolder.marshal(exchange); <---- THIS LINE TO: 
*DefaultExchangeHolder.marshal(exchange, true, true);*
            ObjectMessage answer1 = session.createObjectMessage(answer2);

Since we have several serailizable headers in our routes, for the moment we
will remain on 2.0.15 version, yet It would be great to be able to upgrade
to newer releases.

Thank you

View this message in context:
Sent from the Camel - Users mailing list archive at

View raw message