On Mon, Apr 16, 2012 at 12:58 PM, Ignat <[email protected]> wrote:
> Hi All,
>
> I need to solve following scenario with camel:
>
> While message is being processed in route, I need to record certain
> information based on content being processed. At the end of processing this
> information have to be written to a storage (as a KPI event), clean-up
> executed regardless of success / failure of message.
> During route processing errors with remote components are handled by error
> handler which uses JMS-based retry mechanism.
>
> So far I was able to implement what I need with mixture of onCompletion
> elements per route and custom error handler.
>
> Unfortunately, I do have problem with behavior of onCompletion - it is
> asynchronous, which makes integration tests quite tough (e.g. I can not rely
> on order of events being generated, clean-up  / event writing logic did not
> finish when pipeline is 'complete').
>
> My option would be that onCompletion section would be executed on the same
> thread that process pipeline and producer used to post message to pipeline
> won't return until both logic within pipeline and onCompletion completes.
>
> During my struggle with this scenario I've also tried try / finally logic,
> unfortunately to find that try / finally completely disables error handler
> (and since I used finally-only clause exception itself was not handled and
> error handler was not called).
>
> It is possible that this is just a mis-behavior of 2.4.0, then I will try
> upgrading to more recent one.
>

You can use the API on Exchange to add a on completion (Its called
synchronization).
You may have to use the getUnitOfWork API to get to that point. The
2.4 release is rather old.
If you add using that API then its synchronous.

If you got the Camel in Action book, then see chapter 9, section 9.5
which cover this.

> Thanks in advance.
>
>
>
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/Error-handling-and-invoking-certain-logic-unconditionally-tp5643480p5643480.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
CamelOne 2012 Conference, May 15-16, 2012: http://camelone.com
FuseSource
Email: [email protected]
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Reply via email to