camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Raul Kripalani <r...@evosent.com>
Subject Re: Clearing ThreadLocal when exchange completes
Date Tue, 26 Mar 2013 16:34:28 GMT
Hi David,

The cleanest and most modular way to achieve this is by using
EventNotifiers [1], as they execute synchronously. Enable only the
ExchangeCompletedEvent and add the bean to your registry. The CamelContext
will pick it up automatically.

Beware of the Asynchronous Routing Engine, as it can inadvertently change
the thread in which the response from an endpoint gets processed [2].

Let us know if this helped.

[1]
http://camel.apache.org/eventnotifier-to-log-details-about-all-sent-exchanges.html
[2] http://camel.apache.org/asynchronous-routing-engine.html

*Raúl Kripalani*
Enterprise Architect, Open Source Integration specialist, Program
Manager | Apache
Camel Committer
http://about.me/raulkripalani | http://www.linkedin.com/in/raulkripalani
http://blog.raulkr.net | twitter: @raulvk

On Tue, Mar 26, 2013 at 1:13 PM, davelund <david.r.lund@gmail.com> wrote:

> We are currently using ThreadLocal to store some information that gets
> included in a log4j converter (and is used in other projects that dont have
> camel in). Is there a callback I can use that for all routes in my context
> so that at the end of the route it will get called (without explicitly
> setting it) For example:
> from("jms:somequeue")
>   .processRef("someRandomProcessor")
>   .processRef("someProcessorThatSetsThreadLocalValue")
>   ....
>   .to("jms:someotherqueue")
>
>
> Ideally I'd like the threadlocal cleared when the exchange has been written
> to the queue, without adding a processor that explicitly clears it (as
> developers when adding new routes will forget to do it). I know the
> onCompletion runs in a seperate thread so isn't fit for my purpose. I've
> noticed  syncronisations and unitofworks, but cant seem to find any
> documentation on it. Would this be fit for purpose?
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Clearing-ThreadLocal-when-exchange-completes-tp5729849.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message