On Thu, Sep 8, 2016 at 3:36 PM, Quinn Stevenson
<qu...@pronoia-solutions.com> wrote:
> I made some progress with this.
>
> In my SynchronizationAdapter, I had been calling 
> exchange.getIn().setHeader(…) - I’d never looked to see if there was an “out” 
> message.  Once I changed this to set the header on the out message, the 
> headers started showing up where I wanted them.
>

You can use hasOut() to check if there is OUT message or not.

> Now I’m down to error handling.  If something goes wrong during the 
> acknowledgement, I can set an exception on the exchange and than the route 
> knows that the exchanged failed - I tested this with an 
> onCompletion.onFailureOnly element.
>
> However, the exchanged passed to the onCompletion.onFailureOnly element does 
> NOT have the exception set - so I’m not sure how the route is supposed to 
> tell what happened.  Do I need to do more than just set the exception on the 
> exchange?
>

There is a FAQ about this
http://camel.apache.org/why-is-the-exception-null-when-i-use-onexception.html

> Also, is there a way to get Camel’s error handling to kick-in after the 
> SyncronizationAdapter sets the exception on the exchange?
>
>> On Sep 6, 2016, at 5:06 PM, Quinn Stevenson <qu...@pronoia-solutions.com> 
>> wrote:
>>
>> 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 <claus.ib...@gmail.com> 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
>>> <qu...@pronoia-solutions.com> 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 at?
>>>>
>>>>
>>>>> On Sep 6, 2016, at 1:25 PM, Claus Ibsen <claus.ib...@gmail.com> 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
>>>>> <qu...@pronoia-solutions.com> 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
>>>>> -----------------
>>>>> http://davsclaus.com @davsclaus
>>>>> Camel in Action 2: https://www.manning.com/ibsen2
>>>>
>>>
>>>
>>>
>>> --
>>> Claus Ibsen
>>> -----------------
>>> http://davsclaus.com @davsclaus
>>> Camel in Action 2: https://www.manning.com/ibsen2
>>
>



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2

Reply via email to