I've tried the approach specified below and it seems to work. I'm just interested to know if it works "by accident" or if this is the way the property "Exchange.FAILURE_HANDLED" should be used.
Can someone verify this? /Bengt 2012/4/19 Bengt Rodehav <[email protected]> > I'm using Camel 2.9.1 in our integration platform. Among other things we > have a fairly general file transfer service that logs all file transfers in > a database. If a fail transfer has failed, that fact is recorded along > with the exception that was caught. I have now discovered that if the > exchange first fails but then succeeds in a subsequent retry, it is still > recorded as failed. > > This is probably because of my erroneous logic. I do this to see if it has > failed: > > *Exception cause = theExchange.getProperty(Exchange.EXCEPTION_CAUGHT, > Exception.class);* > *if (theExchange.isFailed() || (cause != null)) {* > * <Regard the exhange as failed>* > > The reason why I can't just use "theExchange.isFailed()" is that it always > returns false for me. I think this is because I use the "moveFailed" > option. I then added a check for an exception. However, once the > EXCEPTION_CAUGHT property is set on an exchange, it will stay there even if > a subsequent retry will succeed. Thus checking for this property is not a > good solution. > > The question then is how I can check if the last retry failed or not. I > have noticed three properties on a failed exchange that look like good > candidates to look for: > > - CamelFailureEndpoint > - CamelFailureHandled > - CamelErrorHandlerHandled > > My instinct says that I should check for the CamelFailureHandled property. > The logic to determine whether an exchange has failed would then be: > > *boolean failureHandled = > (boolean)theExchange.getProperty(Exchange.FAILURE_HANDLED, false);* > *if (theExchange.isFailed() || failureHandled) {* > * <Regard the exhange as failed>* > > Is this a correct (future proof) way of determining if an exhange has > failed? > > /Bengt > > > >
