camel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Quinn Stevenson <>
Subject Re: Help adding logic to camel component that executes before onComplete
Date Tue, 06 Sep 2016 23:06:06 GMT
I’m struggling with this, and I can’t seem to get what I’m after.

I added a SynchronizationAdapter (via addOnCompletion), but the exchange passed to the onComplete
portion of the route still doesn’t have the headers I’m setting in the Syncronizationadapter.
 I’ve tried setting the header in both the onAfterRoute and onComplete methods, but no luck.
 The only place that seems to work is if I add the header in the onBeforeRoute method, but
I don’t have enough information at that point to set the header correctly.

The other thing I’d tried previously that I thought would work was simply setting the headers
in the Consumer, after it called getProcessor().process(exchange) - but that doesn’t work
either.  I’m not sure why that doesn’t work - I set headers before I call getProcessor().process(exchange),
and they behave as I’d expect.  However, anything I do to the exchange after I call getProcessor().process(exchange)
doesn’t seem to have any effect?

Maybe I need to do something different than just call getProcessor().process(exchange)?  Somehow
intercept the flow of the exchange after the last processor in the route, but before before
camel does whatever it does that makes my copy of the exchange irrelevant?

> On Sep 6, 2016, at 2:02 PM, Claus Ibsen <> wrote:
> There is an addOnCompletion on the exchange you can use. Then your
> onCompletion can implement that interface, or extend
> SynchronizationAdapter
> On Tue, Sep 6, 2016 at 9:52 PM, Quinn Stevenson
> <> wrote:
>> Thank you for the prompt reply :-)
>> This sounds like exactly what I need, but I’m a little unclear about how to implement
it.  I tried creating a UnitOfWork, adding a Synchronization, and then setting the UnitOfWork
on the exchange when I create it, but my Synchronization isn’t getting called.
>> is there another component somewhere that does something similar that I could look
>>> On Sep 6, 2016, at 1:25 PM, Claus Ibsen <> wrote:
>>> If you talk about UoW completions with Synchronization:
>>> org.apache.camel.spi.Synchronization
>>> Then you can implement Ordered, and then set the value to be HIGHEST
>>> so this one is run before the others.
>>> On Tue, Sep 6, 2016 at 9:20 PM, Quinn Stevenson
>>> <> wrote:
>>>> I would like to enhance the camel-mllp component to set a message header
containing the MLLP Acknowledgement when the component is automatically generating the acknowledgment.
 This code would need to execute after the last element in the main route, but before any
onCompletion elements are invoked, but I can’t figure out the right way to make this happen.
>>>> Can someone point me in the right direction?
>>> --
>>> Claus Ibsen
>>> -----------------
>>> @davsclaus
>>> Camel in Action 2:
> -- 
> Claus Ibsen
> -----------------
> @davsclaus
> Camel in Action 2:

View raw message