One option is to mark the exception as handled in the exchange. What's happening is that the default error handler is kicking in after your aggregator because it sees an unhandled exception. Alternatively, you can turn off the error handler for that route. It depends on what you're planning to do with the exception.
Elvio -----Original Message----- From: balavino [mailto:[email protected]] Sent: 01 September 2014 05:20 To: [email protected] Subject: Throw checked Exception form a class implementing AggregationStrategy. I have a Parse Exception which is a checked exception to be handled in a class that implements AggregationStrategy. Since it can't be thrown from the class implementing AggregationStrategy i have put a try catch block to handle it, but however i need it to be thrown outside to the next layer. So in the catch block i have set the exception in the exchange by using setException : / try { newPeriod = getPeriod(newExchange); } catch (ParseException e) { if(oldExchange == null){ newExchange.setException(e); System.out.println("Exception set in NE"); } else{ oldExchange.setException(e); System.out.println("Exception set in OE"); } }/ but while in the next processor in the route i tried something as below: / System.out.println("3:"+exchange.getException()); if (exchange.getException() != null) { System.out.println("Exchange has error!!" + exchange.getException()); throw exchange.getException(); }/ But the next processor doesn't event start. The log is as below: a.c.c.file.remote.SftpConsumer - About to process file: RemoteFile[/tmp/snapshot/SNAP_localhost_SUB_PAM_1_99_M_2011-02-M7_period1_0000_20110217-0972.xml] using exchange: Exchange[SNAP_localhost_SUB_PAM_1_99_M_2011-02-M7_period1_0000_20110217-0972.xml] 00:09:45.928 [Camel (AccountSnapshotProcessor) thread #0 - JmsConsumer[rrdb.eventprocessing.accountsnapshot]] DEBUG o.a.c.processor.DefaultErrorHandler - Redelivery enabled: false on error handler: DefaultErrorHandler[Channel[setHeader(subscriberId, XPath: /snapshotRecord/subscriber/subscriberIdentity/@msisdn)]] 00:09:45.938 [Camel (AccountSnapshotProcessor) thread #0 - JmsConsumer[rrdb.eventprocessing.accountsnapshot]] INFO o.a.camel.builder.xml.XPathBuilder - Created default XPathFactory org.apache.xpath.jaxp.XPathFactoryImpl@8c60399 Exception set in NE 1:java.text.ParseException: Unparseable date: "2011-02-M7" Exception set in OE 1:java.text.ParseException: Unparseable date: "2011-02-M7" 00:09:46.187 [Camel (AccountSnapshotProcessor) thread #0 - JmsConsumer[rrdb.eventprocessing.accountsnapshot]] DEBUG o.a.c.processor.MulticastProcessor - Done sequential processing 2 exchanges 00:09:46.188 [Camel (AccountSnapshotProcessor) thread #0 - JmsConsumer[rrdb.eventprocessing.accountsnapshot]] DEBUG org.apache.camel.processor.Pipeline - Message exchange has failed: so breaking out of pipeline for exchange: Exchange[JmsMessage@0x5d4ebf15] Exception: java.text.ParseException: Unparseable date: "2011-02-M7" 00:09:46.194 [Camel (AccountSnapshotProcessor) thread #0 - JmsConsumer[rrdb.eventprocessing.accountsnapshot]] WARN o.a.c.c.jms.EndpointMessageListener - Execution of JMS message listener failed. Caused by: [org.apache.camel.RuntimeCamelException - java.text.ParseException: Unparseable date: "2011-02-M7"] org.apache.camel.RuntimeCamelException: java.text.ParseException: Unparseable date: "2011-02-M7" at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1352) ~[camel-core-2.12.2.jar:2.12.2] at org.apache.camel.component.jms.EndpointMessageListener$EndpointMessageListenerAsyncCallback.done(EndpointMessageListener.java:186) ~[camel-jms-2.12.2.jar:2.12.2] at org.apache.camel.component.jms.EndpointMessageListener.onMessage(EndpointMessageListener.java:107) ~[camel-jms-2.12.2.jar:2.12.2] at org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:562) ~[spring-jms-3.2.4.RELEASE.jar:3.2.4.RELEASE] at org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:500) ~[spring-jms-3.2.4.RELEASE.jar:3.2.4.RELEASE] at org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:468) ~[spring-jms-3.2.4.RELEASE.jar:3.2.4.RELEASE] at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:325) [spring-jms-3.2.4.RELEASE.jar:3.2.4.RELEASE] at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:243) [spring-jms-3.2.4.RELEASE.jar:3.2.4.RELEASE] at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1103) [spring-jms-3.2.4.RELEASE.jar:3.2.4.RELEASE] -- View this message in context: http://camel.465427.n5.nabble.com/Throw-checked-Exception-form-a-class-implementing-AggregationStrategy-tp5755899.html Sent from the Camel - Users mailing list archive at Nabble.com.
