camel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Quinn Stevenson <qu...@pronoia-solutions.com>
Subject Re: Help adding logic to camel component that executes before onComplete
Date Thu, 08 Sep 2016 14:23:35 GMT
Thanks for the quick reply Claus -

I always use the hasOut() to figure out what message to work with in my processors - I’m
not sure why I missed it here the first time around.  I was a little surprised about the out
message being there (since I don’t explicitly use one) - I thought I’d read that the out
message was being deprecated, but it looks like the core engine is using it in this case.
 Anyway, it just reinforced my “always use hasOut” habit :-)

I’d seen that FAQ, but it’s talking about onException elements - I can’t get the onException
elements to fire.  The onCompletion.onCompleteOnly() and onCompletion.onFailureOnly are getting
fired when I expect, but the onException element never gets called.

So does this FAQ apply to onCompletion.onFailureOnly as well?  I just need to look for the
EXCEPTION_CAUGHT property?  I thought I had, but I’ll re-test to make sure.

> On Sep 8, 2016, at 7:41 AM, Claus Ibsen <claus.ibsen@gmail.com> wrote:
> 
> On Thu, Sep 8, 2016 at 3:36 PM, Quinn Stevenson
> <quinn@pronoia-solutions.com <mailto:quinn@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 <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 <quinn@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.ibsen@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
>>>> <quinn@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.ibsen@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
>>>>>> <quinn@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 <http://davsclaus.com/> @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2 <https://www.manning.com/ibsen2>

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