You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Bengt Rodehav <be...@rodehav.com> on 2010/11/26 15:31:01 UTC

onCompletion for failed exchanges

I'm currently implementing a message history store. I use onCompletion to
trigger when to store message details in my store. One piece of critical
information is whether the exchange was successful or not. To determine this
I call the isFailed() method on the exchange but this never seem to evaluate
to true.

My route looks like this:

*
> from("file:in?move=archive/${date:now:yyyyMMdd}/${file:name}&moveFailed=failed/${file:name.noext}-${date:now:yyyyMMddHHmmssSSS}.${file:ext}")
> *

*  .onCompletion()*

*    .process(new FileHistoryProcessor())*

*    .end()*

*  .to("file:out");*


and the process method of the FileHistoryProcessor class looks like this:

*public void process(Exchange theExchange) throws Exception {*

*  if(theExchange.isFailed()) {*

*    // I never get here*

*  }*

*  else {*

*    // I always get here*

*  }*

*}*


If I force an exchange to fail by changing my route to
"....to("file:G:/out") (I don't have a G:), the route fails and the file is
moved to the "failed" folder but *theExchange.isFailed()* is still false.

Have I misunderstood the meaning of isFailed()? If so, how can I detect, in
my onCompletion processor,  whether the exchange successfuly passed through
my route or not?

I use Camel 2.5.0.

/Bengt

Re: onCompletion for failed exchanges

Posted by Bengt Rodehav <be...@rodehav.com>.
Claus,

I did add two but that won't work since they are mutually exclusive -
adding the second one will negate the first one. I assume then, that
the Exchange.EXCHANGE_CAUGHT property is the way to go.

/Bengt

2010/11/29 Claus Ibsen <cl...@gmail.com>:
> On Mon, Nov 29, 2010 at 10:05 AM, Bengt Rodehav <be...@rodehav.com> wrote:
>> Claus,
>>
>> I tried to use both "onCompleteOnly" and "onFailureOnly" but ran into
>> problems. Looking at the source code, it seems like they are mutually
>> exclusive and only the last one will take effect.
>>
>> In my case I always want to be notified when an exchange is completed,
>> both when it succeeds and when it fails, but I need to know whether it
>> failed or not. I guess I will then have to use the "onCompletion"
>> without the "onCompleteOnly" and "onFailureOnly" and instead look at
>> the Exchange.EXCHANGE_CAUGHT property.
>>
>
> Just add two then:
>
> onCompletion.onFailureOnly
>
> onCompletion.onCompleteOnly
>
>
> Or use that  Exchange.EXCHANGE_CAUGHT property
>
>
>> Do you agree?
>>
>> Wouldn't it be convenient to be able to specify different onCompletion
>> processors for successful exchanges and failed exchanges?
>>
>> /Bengt
>>
>>
>>
>> 2010/11/29 Claus Ibsen <cl...@gmail.com>:
>>> This is not a problem in Camel.
>>>
>>> See comment on ticket.
>>>
>>>
>>> --
>>> Claus Ibsen
>>> -----------------
>>> FuseSource
>>> Email: cibsen@fusesource.com
>>> Web: http://fusesource.com
>>> Twitter: davsclaus
>>> Blog: http://davsclaus.blogspot.com/
>>> Author of Camel in Action: http://www.manning.com/ibsen/
>>>
>>
>
>
>
> --
> Claus Ibsen
> -----------------
> FuseSource
> Email: cibsen@fusesource.com
> Web: http://fusesource.com
> Twitter: davsclaus
> Blog: http://davsclaus.blogspot.com/
> Author of Camel in Action: http://www.manning.com/ibsen/
>

Re: onCompletion for failed exchanges

Posted by Claus Ibsen <cl...@gmail.com>.
On Mon, Nov 29, 2010 at 10:05 AM, Bengt Rodehav <be...@rodehav.com> wrote:
> Claus,
>
> I tried to use both "onCompleteOnly" and "onFailureOnly" but ran into
> problems. Looking at the source code, it seems like they are mutually
> exclusive and only the last one will take effect.
>
> In my case I always want to be notified when an exchange is completed,
> both when it succeeds and when it fails, but I need to know whether it
> failed or not. I guess I will then have to use the "onCompletion"
> without the "onCompleteOnly" and "onFailureOnly" and instead look at
> the Exchange.EXCHANGE_CAUGHT property.
>

Just add two then:

onCompletion.onFailureOnly

onCompletion.onCompleteOnly


Or use that  Exchange.EXCHANGE_CAUGHT property


> Do you agree?
>
> Wouldn't it be convenient to be able to specify different onCompletion
> processors for successful exchanges and failed exchanges?
>
> /Bengt
>
>
>
> 2010/11/29 Claus Ibsen <cl...@gmail.com>:
>> This is not a problem in Camel.
>>
>> See comment on ticket.
>>
>>
>> --
>> Claus Ibsen
>> -----------------
>> FuseSource
>> Email: cibsen@fusesource.com
>> Web: http://fusesource.com
>> Twitter: davsclaus
>> Blog: http://davsclaus.blogspot.com/
>> Author of Camel in Action: http://www.manning.com/ibsen/
>>
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Re: onCompletion for failed exchanges

Posted by Bengt Rodehav <be...@rodehav.com>.
Claus,

I tried to use both "onCompleteOnly" and "onFailureOnly" but ran into
problems. Looking at the source code, it seems like they are mutually
exclusive and only the last one will take effect.

In my case I always want to be notified when an exchange is completed,
both when it succeeds and when it fails, but I need to know whether it
failed or not. I guess I will then have to use the "onCompletion"
without the "onCompleteOnly" and "onFailureOnly" and instead look at
the Exchange.EXCHANGE_CAUGHT property.

Do you agree?

Wouldn't it be convenient to be able to specify different onCompletion
processors for successful exchanges and failed exchanges?

/Bengt



2010/11/29 Claus Ibsen <cl...@gmail.com>:
> This is not a problem in Camel.
>
> See comment on ticket.
>
>
> --
> Claus Ibsen
> -----------------
> FuseSource
> Email: cibsen@fusesource.com
> Web: http://fusesource.com
> Twitter: davsclaus
> Blog: http://davsclaus.blogspot.com/
> Author of Camel in Action: http://www.manning.com/ibsen/
>

Re: onCompletion for failed exchanges

Posted by Claus Ibsen <cl...@gmail.com>.
This is not a problem in Camel.

See comment on ticket.


-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Re: onCompletion for failed exchanges

Posted by Bengt Rodehav <be...@rodehav.com>.
Thanks,

/Bengt

2010/11/28 Claus Ibsen <cl...@gmail.com>

> Hi
>
> I have created a ticket
> https://issues.apache.org/jira/browse/CAMEL-3372
>
> On Sun, Nov 28, 2010 at 11:02 AM, Bengt Rodehav <be...@rodehav.com> wrote:
> > Claus,
> >
> > It's not really a big deal but I think most people would expect the
> exchange
> > to be flagged as failed when it, in fact, has failed. If it can be easily
> > implemented then yes I would prefer the exchange to be marked as failed.
> >
> > /Bengt
> >
> > 2010/11/27 Claus Ibsen <cl...@gmail.com>
> >
> >> Hi
> >>
> >> Since the movedFailed is a special feature on file/ftp component I
> >> wonder if we should add a new option to dictate if it should still
> >> mark the Exchange as failed or not. This allows you to let the
> >> onCompletion.onFailureOnly() to do additional stuff.
> >>
> >> Or we should consider it as a bug that the Exchange is not marked as
> >> failed even though you had the moveFailed option enabled, which
> >> handled the failed exchange.
> >>
> >> The moveFailed option was thought as - Okay in case of error just move
> >> the file to X and dont bother me any more. Go on and continue with the
> >> next file.
> >> And hence it didnt flag the Exchange as failed.
> >>
> >> Any thoughts?
> >>
> >>
> >> On Fri, Nov 26, 2010 at 4:09 PM, Bengt Rodehav <be...@rodehav.com>
> wrote:
> >> > I tried the following approach:
> >> >
> >> > - In my onException processor I set a custom property indicating that
> the
> >> > exchange has failed.
> >> > - In my onCompletion processor I regard the exchange as failed if
> >> > theExchange.isFailed() OR my custom property is true.
> >> >
> >> > This seems to do the trick. Are there any gaps I haven't thought of?
> >> >
> >> > Thanks for you reply Andreas. I  haven't tried your approach yet but
> it s
> >> a
> >> > good idea. Basically I will have to handle the moveFailed myself but
> it
> >> > seems pretty easy looking at your example.
> >> >
> >> > /Bengt
> >> >
> >> > 2010/11/26 Andreas A. <an...@gmail.com>
> >> >
> >> >>
> >> >> Hi
> >> >>
> >> >> You could do onCompletion().onFailureOnly() and in the same route as
> you
> >> do
> >> >> the message history route the message to your error destination. This
> of
> >> >> course also means that you have to remove the "moveFailed" option.
> >> >>
> >> >> from("file:in?move=archive/${date:now:yyyyMMdd}/${file:name}")
> >> >> .onCompletion().onFailureOnly()
> >> >>
> >> >>
> >> >>
> >>
> .wireTap("file:failed/${file:name.noext}-${date:now:yyyyMMddHHmmssSSS}.${file:ext}")
> >> >>         .process(new FileHistoryProcessor())*
> >> >>        .end()
> >> >> .to("file:out");
> >> >>
> >> >> Something like that? Not sure about the syntax since I use Spring
> DSL.
> >> >> --
> >> >> View this message in context:
> >> >>
> >>
> http://camel.465427.n5.nabble.com/onCompletion-for-failed-exchanges-tp3281388p3281414.html
> >> >> Sent from the Camel - Users mailing list archive at Nabble.com.
> >> >>
> >> >
> >>
> >>
> >>
> >> --
> >> Claus Ibsen
> >> -----------------
> >> FuseSource
> >> Email: cibsen@fusesource.com
> >> Web: http://fusesource.com
> >> Twitter: davsclaus
> >> Blog: http://davsclaus.blogspot.com/
> >> Author of Camel in Action: http://www.manning.com/ibsen/
> >>
> >
>
>
>
> --
> Claus Ibsen
> -----------------
> FuseSource
> Email: cibsen@fusesource.com
> Web: http://fusesource.com
> Twitter: davsclaus
> Blog: http://davsclaus.blogspot.com/
> Author of Camel in Action: http://www.manning.com/ibsen/
>

Re: onCompletion for failed exchanges

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

I have created a ticket
https://issues.apache.org/jira/browse/CAMEL-3372

On Sun, Nov 28, 2010 at 11:02 AM, Bengt Rodehav <be...@rodehav.com> wrote:
> Claus,
>
> It's not really a big deal but I think most people would expect the exchange
> to be flagged as failed when it, in fact, has failed. If it can be easily
> implemented then yes I would prefer the exchange to be marked as failed.
>
> /Bengt
>
> 2010/11/27 Claus Ibsen <cl...@gmail.com>
>
>> Hi
>>
>> Since the movedFailed is a special feature on file/ftp component I
>> wonder if we should add a new option to dictate if it should still
>> mark the Exchange as failed or not. This allows you to let the
>> onCompletion.onFailureOnly() to do additional stuff.
>>
>> Or we should consider it as a bug that the Exchange is not marked as
>> failed even though you had the moveFailed option enabled, which
>> handled the failed exchange.
>>
>> The moveFailed option was thought as - Okay in case of error just move
>> the file to X and dont bother me any more. Go on and continue with the
>> next file.
>> And hence it didnt flag the Exchange as failed.
>>
>> Any thoughts?
>>
>>
>> On Fri, Nov 26, 2010 at 4:09 PM, Bengt Rodehav <be...@rodehav.com> wrote:
>> > I tried the following approach:
>> >
>> > - In my onException processor I set a custom property indicating that the
>> > exchange has failed.
>> > - In my onCompletion processor I regard the exchange as failed if
>> > theExchange.isFailed() OR my custom property is true.
>> >
>> > This seems to do the trick. Are there any gaps I haven't thought of?
>> >
>> > Thanks for you reply Andreas. I  haven't tried your approach yet but it s
>> a
>> > good idea. Basically I will have to handle the moveFailed myself but it
>> > seems pretty easy looking at your example.
>> >
>> > /Bengt
>> >
>> > 2010/11/26 Andreas A. <an...@gmail.com>
>> >
>> >>
>> >> Hi
>> >>
>> >> You could do onCompletion().onFailureOnly() and in the same route as you
>> do
>> >> the message history route the message to your error destination. This of
>> >> course also means that you have to remove the "moveFailed" option.
>> >>
>> >> from("file:in?move=archive/${date:now:yyyyMMdd}/${file:name}")
>> >> .onCompletion().onFailureOnly()
>> >>
>> >>
>> >>
>> .wireTap("file:failed/${file:name.noext}-${date:now:yyyyMMddHHmmssSSS}.${file:ext}")
>> >>         .process(new FileHistoryProcessor())*
>> >>        .end()
>> >> .to("file:out");
>> >>
>> >> Something like that? Not sure about the syntax since I use Spring DSL.
>> >> --
>> >> View this message in context:
>> >>
>> http://camel.465427.n5.nabble.com/onCompletion-for-failed-exchanges-tp3281388p3281414.html
>> >> Sent from the Camel - Users mailing list archive at Nabble.com.
>> >>
>> >
>>
>>
>>
>> --
>> Claus Ibsen
>> -----------------
>> FuseSource
>> Email: cibsen@fusesource.com
>> Web: http://fusesource.com
>> Twitter: davsclaus
>> Blog: http://davsclaus.blogspot.com/
>> Author of Camel in Action: http://www.manning.com/ibsen/
>>
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Re: onCompletion for failed exchanges

Posted by Bengt Rodehav <be...@rodehav.com>.
Claus,

It's not really a big deal but I think most people would expect the exchange
to be flagged as failed when it, in fact, has failed. If it can be easily
implemented then yes I would prefer the exchange to be marked as failed.

/Bengt

2010/11/27 Claus Ibsen <cl...@gmail.com>

> Hi
>
> Since the movedFailed is a special feature on file/ftp component I
> wonder if we should add a new option to dictate if it should still
> mark the Exchange as failed or not. This allows you to let the
> onCompletion.onFailureOnly() to do additional stuff.
>
> Or we should consider it as a bug that the Exchange is not marked as
> failed even though you had the moveFailed option enabled, which
> handled the failed exchange.
>
> The moveFailed option was thought as - Okay in case of error just move
> the file to X and dont bother me any more. Go on and continue with the
> next file.
> And hence it didnt flag the Exchange as failed.
>
> Any thoughts?
>
>
> On Fri, Nov 26, 2010 at 4:09 PM, Bengt Rodehav <be...@rodehav.com> wrote:
> > I tried the following approach:
> >
> > - In my onException processor I set a custom property indicating that the
> > exchange has failed.
> > - In my onCompletion processor I regard the exchange as failed if
> > theExchange.isFailed() OR my custom property is true.
> >
> > This seems to do the trick. Are there any gaps I haven't thought of?
> >
> > Thanks for you reply Andreas. I  haven't tried your approach yet but it s
> a
> > good idea. Basically I will have to handle the moveFailed myself but it
> > seems pretty easy looking at your example.
> >
> > /Bengt
> >
> > 2010/11/26 Andreas A. <an...@gmail.com>
> >
> >>
> >> Hi
> >>
> >> You could do onCompletion().onFailureOnly() and in the same route as you
> do
> >> the message history route the message to your error destination. This of
> >> course also means that you have to remove the "moveFailed" option.
> >>
> >> from("file:in?move=archive/${date:now:yyyyMMdd}/${file:name}")
> >> .onCompletion().onFailureOnly()
> >>
> >>
> >>
> .wireTap("file:failed/${file:name.noext}-${date:now:yyyyMMddHHmmssSSS}.${file:ext}")
> >>         .process(new FileHistoryProcessor())*
> >>        .end()
> >> .to("file:out");
> >>
> >> Something like that? Not sure about the syntax since I use Spring DSL.
> >> --
> >> View this message in context:
> >>
> http://camel.465427.n5.nabble.com/onCompletion-for-failed-exchanges-tp3281388p3281414.html
> >> Sent from the Camel - Users mailing list archive at Nabble.com.
> >>
> >
>
>
>
> --
> Claus Ibsen
> -----------------
> FuseSource
> Email: cibsen@fusesource.com
> Web: http://fusesource.com
> Twitter: davsclaus
> Blog: http://davsclaus.blogspot.com/
> Author of Camel in Action: http://www.manning.com/ibsen/
>

Re: onCompletion for failed exchanges

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Since the movedFailed is a special feature on file/ftp component I
wonder if we should add a new option to dictate if it should still
mark the Exchange as failed or not. This allows you to let the
onCompletion.onFailureOnly() to do additional stuff.

Or we should consider it as a bug that the Exchange is not marked as
failed even though you had the moveFailed option enabled, which
handled the failed exchange.

The moveFailed option was thought as - Okay in case of error just move
the file to X and dont bother me any more. Go on and continue with the
next file.
And hence it didnt flag the Exchange as failed.

Any thoughts?


On Fri, Nov 26, 2010 at 4:09 PM, Bengt Rodehav <be...@rodehav.com> wrote:
> I tried the following approach:
>
> - In my onException processor I set a custom property indicating that the
> exchange has failed.
> - In my onCompletion processor I regard the exchange as failed if
> theExchange.isFailed() OR my custom property is true.
>
> This seems to do the trick. Are there any gaps I haven't thought of?
>
> Thanks for you reply Andreas. I  haven't tried your approach yet but it s a
> good idea. Basically I will have to handle the moveFailed myself but it
> seems pretty easy looking at your example.
>
> /Bengt
>
> 2010/11/26 Andreas A. <an...@gmail.com>
>
>>
>> Hi
>>
>> You could do onCompletion().onFailureOnly() and in the same route as you do
>> the message history route the message to your error destination. This of
>> course also means that you have to remove the "moveFailed" option.
>>
>> from("file:in?move=archive/${date:now:yyyyMMdd}/${file:name}")
>> .onCompletion().onFailureOnly()
>>
>>
>> .wireTap("file:failed/${file:name.noext}-${date:now:yyyyMMddHHmmssSSS}.${file:ext}")
>>         .process(new FileHistoryProcessor())*
>>        .end()
>> .to("file:out");
>>
>> Something like that? Not sure about the syntax since I use Spring DSL.
>> --
>> View this message in context:
>> http://camel.465427.n5.nabble.com/onCompletion-for-failed-exchanges-tp3281388p3281414.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Re: onCompletion for failed exchanges

Posted by Bengt Rodehav <be...@rodehav.com>.
I tried the following approach:

- In my onException processor I set a custom property indicating that the
exchange has failed.
- In my onCompletion processor I regard the exchange as failed if
theExchange.isFailed() OR my custom property is true.

This seems to do the trick. Are there any gaps I haven't thought of?

Thanks for you reply Andreas. I  haven't tried your approach yet but it s a
good idea. Basically I will have to handle the moveFailed myself but it
seems pretty easy looking at your example.

/Bengt

2010/11/26 Andreas A. <an...@gmail.com>

>
> Hi
>
> You could do onCompletion().onFailureOnly() and in the same route as you do
> the message history route the message to your error destination. This of
> course also means that you have to remove the "moveFailed" option.
>
> from("file:in?move=archive/${date:now:yyyyMMdd}/${file:name}")
> .onCompletion().onFailureOnly()
>
>
> .wireTap("file:failed/${file:name.noext}-${date:now:yyyyMMddHHmmssSSS}.${file:ext}")
>         .process(new FileHistoryProcessor())*
>        .end()
> .to("file:out");
>
> Something like that? Not sure about the syntax since I use Spring DSL.
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/onCompletion-for-failed-exchanges-tp3281388p3281414.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Re: onCompletion for failed exchanges

Posted by "Andreas A." <an...@gmail.com>.
Hi

You could do onCompletion().onFailureOnly() and in the same route as you do
the message history route the message to your error destination. This of
course also means that you have to remove the "moveFailed" option.

from("file:in?move=archive/${date:now:yyyyMMdd}/${file:name}") 
.onCompletion().onFailureOnly()

.wireTap("file:failed/${file:name.noext}-${date:now:yyyyMMddHHmmssSSS}.${file:ext}")
	.process(new FileHistoryProcessor())* 
	.end()
.to("file:out");

Something like that? Not sure about the syntax since I use Spring DSL.
-- 
View this message in context: http://camel.465427.n5.nabble.com/onCompletion-for-failed-exchanges-tp3281388p3281414.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: onCompletion for failed exchanges

Posted by Bengt Rodehav <be...@rodehav.com>.
OK, I think I understand the problem. Do you have any suggestions as to how
I can keep using moveFailed but determine in onCompletion that this was
done?

Actually, I also do the following:

*onException(Exception.class)*

*  .maximumRedeliveries(mMaxRedeliveryAttempts)*

*  .delayPattern(mDelayPattern)*

*  .process(new LogProcessor(getName()));*


The purpose is to log any failed files (and later on notify the user in a
better way). Is this a good place to set a custom property on the exchange
to mark it as "failed" and then later look at this property in the
onCompletion?

Is there a best practice for this?

/Bengt

2010/11/26 Claus Ibsen <cl...@gmail.com>

> You use the moveFailed option on the file component which means it
> handles the failures and mark the Exchange is completed.
>
>
>
> On Fri, Nov 26, 2010 at 3:31 PM, Bengt Rodehav <be...@rodehav.com> wrote:
> > I'm currently implementing a message history store. I use onCompletion to
> > trigger when to store message details in my store. One piece of critical
> > information is whether the exchange was successful or not. To determine
> this
> > I call the isFailed() method on the exchange but this never seem to
> evaluate
> > to true.
> >
> > My route looks like this:
> >
> > *
> >>
> from("file:in?move=archive/${date:now:yyyyMMdd}/${file:name}&moveFailed=failed/${file:name.noext}-${date:now:yyyyMMddHHmmssSSS}.${file:ext}")
> >> *
> >
> > *  .onCompletion()*
> >
> > *    .process(new FileHistoryProcessor())*
> >
> > *    .end()*
> >
> > *  .to("file:out");*
> >
> >
> > and the process method of the FileHistoryProcessor class looks like this:
> >
> > *public void process(Exchange theExchange) throws Exception {*
> >
> > *  if(theExchange.isFailed()) {*
> >
> > *    // I never get here*
> >
> > *  }*
> >
> > *  else {*
> >
> > *    // I always get here*
> >
> > *  }*
> >
> > *}*
> >
> >
> > If I force an exchange to fail by changing my route to
> > "....to("file:G:/out") (I don't have a G:), the route fails and the file
> is
> > moved to the "failed" folder but *theExchange.isFailed()* is still false.
> >
> > Have I misunderstood the meaning of isFailed()? If so, how can I detect,
> in
> > my onCompletion processor,  whether the exchange successfuly passed
> through
> > my route or not?
> >
> > I use Camel 2.5.0.
> >
> > /Bengt
> >
>
>
>
> --
> Claus Ibsen
> -----------------
> FuseSource
> Email: cibsen@fusesource.com
> Web: http://fusesource.com
> Twitter: davsclaus
> Blog: http://davsclaus.blogspot.com/
> Author of Camel in Action: http://www.manning.com/ibsen/
>

Re: onCompletion for failed exchanges

Posted by Claus Ibsen <cl...@gmail.com>.
You use the moveFailed option on the file component which means it
handles the failures and mark the Exchange is completed.



On Fri, Nov 26, 2010 at 3:31 PM, Bengt Rodehav <be...@rodehav.com> wrote:
> I'm currently implementing a message history store. I use onCompletion to
> trigger when to store message details in my store. One piece of critical
> information is whether the exchange was successful or not. To determine this
> I call the isFailed() method on the exchange but this never seem to evaluate
> to true.
>
> My route looks like this:
>
> *
>> from("file:in?move=archive/${date:now:yyyyMMdd}/${file:name}&moveFailed=failed/${file:name.noext}-${date:now:yyyyMMddHHmmssSSS}.${file:ext}")
>> *
>
> *  .onCompletion()*
>
> *    .process(new FileHistoryProcessor())*
>
> *    .end()*
>
> *  .to("file:out");*
>
>
> and the process method of the FileHistoryProcessor class looks like this:
>
> *public void process(Exchange theExchange) throws Exception {*
>
> *  if(theExchange.isFailed()) {*
>
> *    // I never get here*
>
> *  }*
>
> *  else {*
>
> *    // I always get here*
>
> *  }*
>
> *}*
>
>
> If I force an exchange to fail by changing my route to
> "....to("file:G:/out") (I don't have a G:), the route fails and the file is
> moved to the "failed" folder but *theExchange.isFailed()* is still false.
>
> Have I misunderstood the meaning of isFailed()? If so, how can I detect, in
> my onCompletion processor,  whether the exchange successfuly passed through
> my route or not?
>
> I use Camel 2.5.0.
>
> /Bengt
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/