2 Replies Latest reply on Jan 1, 2017 3:17 PM by barbara_devido

    Custom Exchange property across routes?

    mikefinnx

      Hi All,

       

      Apologies if this has come up before, but I am not having much luck finding an answer.

       

      I have a need to carry some metadata along with an exchange (across multiple routes and WARs via JMS). I understand that header objects don't necessarily survive the marshal/unmarshal for transport between routes (particularly with JMS), so am looking at using a custom bean object as an exchange property (per recommendations I have seen on the web) to carry the metadata attribs. However, I am unable to get the property object to make it between routes. I have tried 'transferExchange' on the jms to (and from) to no avail, and my bean is serializable. On the receiving route end, the property is not on the exchange and no warns or errors in the log. I have tried it with a simple string property and it seems to work fine with that.

       

      My question is - should this work? Should I be able to pass a custom object (bean) across JMS between routes as an Exchange property?

       

      Using FUSE 6.2.1 (Camel 2.17.0.redhat-630187) on EAP 6.4.11

       

      Any help appreciated.

       

      Thanks,

      Mike

        • 1. Re: Custom Exchange property across routes?
          mikefinnx

          Sorry, that's FUSE 6.3.0 not 6.2.1.

          • 2. Re: Custom Exchange property across routes?
            barbara_devido

            Hi

             

            I have the same problem.

             

            In Fuse 6.2.1 I was able to set a custom object in the header of my exchange and as long as it was serializable and the container consuming the route had this JVM options set (-Dorg.apache.activemq.SERIALIZABLE_PACKAGES="*") and the queue had for both producer and consumer the option "transferExchange=true" everything was working fine. Now in Fuse 6.3.0 it is not working anymore.

             

            To make a simple example, there is not need to have a custom object, it can be a Calendar object.

            Since I'd like to upgrade a Customer production enviroment from Fuse 6.2.1 to Fuse 6.3.0 and could not understand what was going on, I decided to debug the code, and I noticed a big change in the org.apache.camel.impl.DefaultExchangeHolder class. It is used by the org.apache.camel.component.jms.JmsBinding#createJmsMessage(org.apache.camel.Exchange, java.lang.Object, java.util.Map<java.lang.String,java.lang.Object>, Session, org.apache.camel.CamelContext).

             

            I believe the problem is here:

             

            public static DefaultExchangeHolder marshal(Exchange exchange) {

               return marshal(exchange, true, false); <---- THE FALSE PARAMETER AVOID THE MARSHAL OF COMPLEX TYPE

            }

             

            In Fuse 6.2.1 the class is quite different.

             

            I know it is a problem of Apache Camel 2.0.17, I have no idea though if the code is different in newer version.

             

            This is a big change and it is not documented since if I look at the Camel page, it clearly states that if transferExchange is true than

            "You can transfer the exchange over the wire instead of just the body and headers. The following fields are transferred: In body, Out body, Fault body, In headers, Out headers, Fault headers, exchange properties, exchange exception. This requires that the objects are serializable. Camel will exclude any non-serializable objects and log it at WARN level.

            You must enable this option on both the producer and the consumer side, so Camel will know that the payload is an Exchange and not a regular payload."

             

            There is any workaround in order to make this whole thing work as is should work?

             

            Thank you

            Barbara