Hi All,
Here is my route. The goal I am trying to achieve is to send a STATUS
(0=success, 1= failure) back to the caller. It works for a successful
execution. I am returning a 0 from the onCompletion().
When the route fails at the ".unmarshal(beanIO)" step I need to stop
processing the route any further, and reply back with a 0 to the consumer on
"direct:routeStatus".
But, As of now, the route does not stop on exception as it is handled it in
doCatch(). How can I stop the route here and send a response back? Currently
it gives me an error saying "no consumers present on direct:routeStatus".
Why is this a problem when it was working for the success scenario?
Does the onCompletion() execute even on exception cases?
When I try to use one single try catch(), It is giving me an error saying
ChoiceDefinition do not support doCatch(). Why is it so ?
onException(Exception.class).handled(true).maximumRedeliveries(0)
.setBody(constant(1))
.log("Returning Status of the route: ${body}")
.to("direct:routeStatus");
from(getDirectEndPoint()).routeId(getRouteId())
.onCompletion()
.setBody(constant(0)).to("direct:routeStatus")
.end()
.pollEnrich(getFileEndPoint())
.beanRef("loggingBean", "logDebug(${id},
'"+this.getClass().getName()+"',
'Reading Flat File')")
.doTry()
.unmarshal(beanIO)
.doCatch(Throwable.class)
.beanRef("loggingBean", "endError(${id},
'"+this.getClass().getName()+"', ${exception}, 'Exception while
Unmarshalling File : ${header.CamelFileName} ')")
.end()
.split(body())
.choice()
.when(transactionRecord)
.choice()
.when(UNDERNOTICE_OR_RESCISSION)
.doTry()
.bean(PolicyStatusRequestHelper.class,"getStatusRequest")
.marshal().json()
.inOut(getJmsEndPoint())
.beanRef("loggingBean", "logDebug( ${id},
'"+this.getClass().getName()+"', 'Transaction Status :"+ simple("${body}")
+"')")
.doCatch(Throwable.class)
.beanRef("loggingBean", "endError(${id},
'"+this.getClass().getName()+"', ${exception}, 'Exception while sending
StatusRequest to JMS queue')")
.end();
How can I properly use onException() in my above route to achieve the same?
I tried putting it at different places. But nothing seems to work. I am not
able to propagate the exception properly.
Can anyone really help with this?
THanks !
--
View this message in context:
http://camel.465427.n5.nabble.com/Issue-with-using-onException-tp5732200.html
Sent from the Camel - Users mailing list archive at Nabble.com.