Hi

>Hello again Babak,
>
>I have got to associate own custom ExceptionHandler to the Consumer of my
>FTP Route. But I continue to have problems to control
>"renaming/moving/deleting" of FTP.
>
>I have followed the code and the problem is that the ExceptionHandler of
>the Consumer is diferente of GenericFileOnCompletion.

Yeah that's the way it is right now by the existing code. There're two
different corners having ExceptionHandler injected to them:

A: On GenericFileConsumer inherited from DefaultConsumer
B: On GenericFileOnCompletion itself


>
>During the execution of FTP route is invoked the method
>*processExchange*of the class
>* GenericFileConsumer<T> *then a "OnCompletion" is added of this way:
>
>*exchange.addOnCompletion(new GenericFileOnCompletion<T>(endpoint,
>operations, target, absoluteFileName));*
>
>The exceptionHandler of this GenericFileOnCompletion is null, I belived
>that it used the exceptionHandler of the Consumer. And like you indicated
>me, if exceptionHandler is null then the LoggingExceptionHandler is used.
>
>The key is  to change the ExceptionHandler of  GenericFileOnCompletion but
>I don't know how do it.

O.K. What I tried to show you was a solution to provide a custom
ExceptionHandler for the corner A but if you want to do the same for the
corner B as well then just forget the already preexisting
GenericFileOnCompletion added by GenericFileConsumer itself. Just add
*one* more Synchronization of *yours* as well on the exchange:


   from("...")Š
     .process(new Processor() {
        public void process(Exchange exchange) throws Exception {
            Synchronization mySynchronizationImpl = ...

            exchange.addOnCompletion(myOnCompletion);
        }).
   to("...");

And by your Synchronization react accordingly on the

   void onFailure(Exchange exchange);


callback by your mySynchronizationImpl.


>
>I have reread your advice and I have some doubt. First you say:
>
>" If you want to react differently on an encountered exception you can
>inject your own custom ExceptionHandler (for example into a FileConsumer)"

Yes the unit-test I already provided demonstrates this case. However it
seems this is not what you want, so as already said *add* your *own*
custom Synchronization on the inflight exchange.

>
>I think like this class uses "new" is not possible inject the my
>ExceptionHandler to the GenericFileOnCompletion. Is it?

I don't understand this question.

>
>On the other hand, you indicated me that other solution would be:
>
> "provide your own Synchronization implementation and do:
>
>exchange.addOnCompletion(MyHandler)
>
>For example from inside a Processor inside your route"
>
>In this case,  will MyHandler be a simple class that implements
>Synchonization?

Exactly, see the sample route above.

>
>How  can I control with MyHandler the Exceptions of the "other"
>addOnCompletion? I mean, the Exceptions don't control of the "other"
>addOnCompletion are the problems during the "renaming/moving/deleting"

Don't worry about other preexisting attached Synchronizations on the
exchange object, just concentrate on your *own* implementation. For
example when there's a failure event then Synchronization.onFailure
() method of *all* attached Synchronizations on exchange get a callback
one after the other and each can react on the failure the way they want.
See UnitOfWorkHelper.doneSynchronizations().

Last but not least by no means what I'm explaining here should be
understood as the best way to solve your problem and maybe others on the
forum have got a better idea for your use case.

Babak

>
>Thank you again.
>
>
>--
>View this message in context:
>http://camel.465427.n5.nabble.com/ExceptionHandler-in-a-ftp-Route-tp545146
>6p5463890.html
>Sent from the Camel - Users mailing list archive at Nabble.com.


Reply via email to