You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by anton_nazarov <na...@telkom.co.za> on 2011/11/03 08:51:43 UTC

transferring a data wrapper-object along the route

Hi,

I've got quite a long route which consists of 5-6 handler/to's clauses.
Starting from the first handler I create a data transfer object (some
business transaction specific info) which I populate with additional
information on every step. In the end of the route I serialize that object,
using JPA. I can't use body, since body is been used to transfer the
business process- specific messages.

Currently, I use exchange.setProperty() to store that object:
        BusinessTransaction transaction = prepareTransactionObject(keys,
messagePayload);
        exchange.setProperty(BusinessTransaction.TRANSACTION_PROPERTY,
transaction);

In every sequential handler I extract the BusinessTransaction object from
the Exchange property:    
exchange.getProperty(BusinessTransaction.TRANSACTION_PROPERTY,
BusinessTransaction.class);

... and populate is with new information. 

Question:
Is that way safe (e.g. thread safe), or, perhaps, there are other
recommendations (using headers, for example) to transfer accompanying
information along the long route?

Thanks,

Anton

--
View this message in context: http://camel.465427.n5.nabble.com/transferring-a-data-wrapper-object-along-the-route-tp4960377p4960377.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: transferring a data wrapper-object along the route

Posted by anton_nazarov <na...@telkom.co.za>.
Claus,

Thank you for the clarification.

regards,

Anton

--
View this message in context: http://camel.465427.n5.nabble.com/transferring-a-data-wrapper-object-along-the-route-tp4960377p4960768.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: transferring a data wrapper-object along the route

Posted by Claus Ibsen <cl...@gmail.com>.
On Thu, Nov 3, 2011 at 8:51 AM, anton_nazarov <na...@telkom.co.za> wrote:
> Hi,
>
> I've got quite a long route which consists of 5-6 handler/to's clauses.
> Starting from the first handler I create a data transfer object (some
> business transaction specific info) which I populate with additional
> information on every step. In the end of the route I serialize that object,
> using JPA. I can't use body, since body is been used to transfer the
> business process- specific messages.
>
> Currently, I use exchange.setProperty() to store that object:
>        BusinessTransaction transaction = prepareTransactionObject(keys,
> messagePayload);
>        exchange.setProperty(BusinessTransaction.TRANSACTION_PROPERTY,
> transaction);
>
> In every sequential handler I extract the BusinessTransaction object from
> the Exchange property:
> exchange.getProperty(BusinessTransaction.TRANSACTION_PROPERTY,
> BusinessTransaction.class);
>
> ... and populate is with new information.
>
> Question:
> Is that way safe (e.g. thread safe), or, perhaps, there are other
> recommendations (using headers, for example) to transfer accompanying
> information along the long route?
>

Thats a good solution to store as property on the exchange, as it will
be available for the entire lifecycle of the Exchange.

If you store in headers, then objects may be discarded if sending over
transports and getting a reply message back etc.
So use exchange properties for objects you want to keep around, and
which are not part of the message details (body or header).

And yes its thread safe.



> Thanks,
>
> Anton
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/transferring-a-data-wrapper-object-along-the-route-tp4960377p4960377.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/