You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Neeraj Mahajan <ne...@specsavers.com> on 2012/08/17 18:05:44 UTC

Aggregator not propagating exception back in camel version 1.6.2

I am calling a route from Aggregator using direct component once  aggregation 
is complete. 
When the called direct route throws any Exception I expect that aggregator
*should not handle* that exception, but the problem I am facing is that the
exception is being getting handled by the aggregator which i dont require.

I am using camel *1.6.2 version* and i can't ugrade to newer versions.
Following is code snippet i am using

<route id="splitterRoute" errorHandlerRef="noErrorHandlerBuilder">
<splitter>
                <xpath>/ord:orderSet/ord:orders/ord:order</xpath>
		<process ref="myProcessor" />
		<to uri="direct:aggregatorRoute" />
</splitter>
</route>

<route id="aggregatorRoute" errorHandlerRef="noErrorHandlerBuilder">
			<from uri="direct:aggregatorRoute" />
			<aggregator strategyRef="aggregatorStrategy" >
				<simple>header.JMSCorrelationID</simple>
				<to uri="direct:responseGenerationRoute"/>
				<completedPredicate>
					<methodCall bean="aggregationCompletionStrategy"
method="aggregationComplete" />
				</completedPredicate>
			</aggregator>
</route>

<route id="responseGenerationRoute" errorHandlerRef="noErrorHandlerBuilder">
		<from uri="direct:responseGenerationRoute" />
		<process ref="responseGenerationProcessor" />
			<recipientList>
				<header>responseDestination</header>
			</recipientList>
</route>

It will be helpfull, If someone can provide any direction on this.

Thanks in Advance
Neeraj




--
View this message in context: http://camel.465427.n5.nabble.com/Aggregator-not-propagating-exception-back-in-camel-version-1-6-2-tp5717629.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Aggregator not propagating exception back in camel version 1.6.2

Posted by Neeraj Mahajan <ne...@specsavers.com>.
Thanks Claus

Now I think i have to use some thing else intead of aggregator as i cant
upgrate the version.

Thanks for your valuable support and time.
Neeraj Mahajan



--
View this message in context: http://camel.465427.n5.nabble.com/Aggregator-not-propagating-exception-back-in-camel-version-1-6-2-tp5717629p5717693.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Aggregator not propagating exception back in camel version 1.6.2

Posted by Claus Ibsen <cl...@gmail.com>.
On Mon, Aug 20, 2012 at 9:29 AM, Neeraj Mahajan
<ne...@specsavers.com> wrote:
> I have intentionally disabled the error handlling, As I *required the message
> to be redelivered* in case of any exception/error in any route. I have
> applied transaction policy in my root route(not shown here in the above code
> sniphet) from where this splitter and aggregator gets called.
>

The Aggregator EIP in Camel 1.x does *not* support redelivery or
persistent storage out of the box.
You would need Camel 2.3 onwards for that.

If an exception occurs, you would have to deal with that and handle
your own kind of redelivery.



> Thanks
> Neeraj Mahajan
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Aggregator-not-propagating-exception-back-in-camel-version-1-6-2-tp5717629p5717689.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, fusenews
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: Aggregator not propagating exception back in camel version 1.6.2

Posted by Neeraj Mahajan <ne...@specsavers.com>.
I have intentionally disabled the error handlling, As I *required the message
to be redelivered* in case of any exception/error in any route. I have
applied transaction policy in my root route(not shown here in the above code
sniphet) from where this splitter and aggregator gets called.

Thanks
Neeraj Mahajan



--
View this message in context: http://camel.465427.n5.nabble.com/Aggregator-not-propagating-exception-back-in-camel-version-1-6-2-tp5717629p5717689.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Aggregator not propagating exception back in camel version 1.6.2

Posted by Claus Ibsen <cl...@gmail.com>.
On Mon, Aug 20, 2012 at 8:44 AM, Neeraj Mahajan
<ne...@specsavers.com> wrote:
> Once aggregated result(exchange) is commited, the control does not come back
> to the aggregation strategy. And also I dont want to handle the exception, I
> need it to be progagated back from the aggregator component.
>

You have disabled error handling in your direct route. You would need
to re-enable that and use the Camel error handler to deal with the
exceptions.

> Thanks
> Neeraj Mahajan
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Aggregator-not-propagating-exception-back-in-camel-version-1-6-2-tp5717629p5717685.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, fusenews
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: Aggregator not propagating exception back in camel version 1.6.2

Posted by Neeraj Mahajan <ne...@specsavers.com>.
Once aggregated result(exchange) is commited, the control does not come back
to the aggregation strategy. And also I dont want to handle the exception, I
need it to be progagated back from the aggregator component.

Thanks
Neeraj Mahajan



--
View this message in context: http://camel.465427.n5.nabble.com/Aggregator-not-propagating-exception-back-in-camel-version-1-6-2-tp5717629p5717685.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Aggregator not propagating exception back in camel version 1.6.2

Posted by Claus Ibsen <cl...@gmail.com>.
On Mon, Aug 20, 2012 at 8:22 AM, Neeraj Mahajan
<ne...@specsavers.com> wrote:
> Thanks again
>
> So is there any way in camel 1.6.2, by which we can tell the aggregator not
> to handle the exception.
>

You can try removing the exception by setting it to null with
setException(null) on the exchange you return from the aggregation
strategy.


> Neeraj Mahajan
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Aggregator-not-propagating-exception-back-in-camel-version-1-6-2-tp5717629p5717683.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, fusenews
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: Aggregator not propagating exception back in camel version 1.6.2

Posted by Neeraj Mahajan <ne...@specsavers.com>.
Thanks again

So is there any way in camel 1.6.2, by which we can tell the aggregator not
to handle the exception.

Neeraj Mahajan



--
View this message in context: http://camel.465427.n5.nabble.com/Aggregator-not-propagating-exception-back-in-camel-version-1-6-2-tp5717629p5717683.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Aggregator not propagating exception back in camel version 1.6.2

Posted by Claus Ibsen <cl...@gmail.com>.
On Mon, Aug 20, 2012 at 7:43 AM, Neeraj Mahajan
<ne...@specsavers.com> wrote:
> Thanks Claus for your quick reply.
> The exception is not coming while doing the aggragation, Actually exception
> is coming once my aggregation is complete and aggregation component sends
> the aggregated response to the *next direct route*, which actually throws
> the exception. Once aggregated mesage is send to the next route, I believe
> the *aggregation stratergy does not play* any role, so can't handled my
> exception there.
>

Ah yeah that was the old behavior in Camel 1.x. And one of the reasons
why we re-wrote the aggregator in Camel 2.x onwards.
In 2.x it aggregates on-the-fly, where as in 1.x it does that in a
batch when complete.


> Following is the stack trace of the exception I am getting
> ERROR - Aggregator                     - Response Genereration Exception
> com.transition.ResponseGenerationException: Response Genereration Exception
>         at
> com.transition.processors.ResponseGenerationProcessor.process(ResponseGenerationProcessor.java:67)
>         at
> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:80)
>         at org.apache.camel.processor.Pipeline.process(Pipeline.java:115)
>         at org.apache.camel.processor.Pipeline.process(Pipeline.java:89)
>         at
> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:68)
>         at
> org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:70)
>         at
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:41)
>         at
> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:66)
>         at
> org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:47)
>         at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:69)
>         at
> org.apache.camel.processor.BatchProcessor.processExchange(BatchProcessor.java:151)
>         at
> org.apache.camel.processor.BatchProcessor$BatchSender.sendExchanges(BatchProcessor.java:293)
>         at
> org.apache.camel.processor.BatchProcessor$BatchSender.run(BatchProcessor.java:238)
>
>
> The solution I am thinking is to override the handleException method of the
> Error handler which aggregator uses by default(I check the api when
> org.apache.camel.processor.BatchProcessor$BatchSender.sendExchanges(BatchProcessor.java:293)
> method is called, the catch block calls the handleException method which
> actually handle the aggregator exception). But I am not able to find, how I
> can set the error handler for my aggregator component.
>
> Please suggest if this can be done, or if there is some better solution to
> resolve the issue.
>
> Thanks
> Neeraj Mahajan
>
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Aggregator-not-propagating-exception-back-in-camel-version-1-6-2-tp5717629p5717676.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, fusenews
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: Aggregator not propagating exception back in camel version 1.6.2

Posted by Neeraj Mahajan <ne...@specsavers.com>.
Thanks Claus for your quick reply.
The exception is not coming while doing the aggragation, Actually exception
is coming once my aggregation is complete and aggregation component sends
the aggregated response to the *next direct route*, which actually throws
the exception. Once aggregated mesage is send to the next route, I believe
the *aggregation stratergy does not play* any role, so can't handled my
exception there.

Following is the stack trace of the exception I am getting
ERROR - Aggregator                     - Response Genereration Exception
com.transition.ResponseGenerationException: Response Genereration Exception
	at
com.transition.processors.ResponseGenerationProcessor.process(ResponseGenerationProcessor.java:67)
	at
org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:80)
	at org.apache.camel.processor.Pipeline.process(Pipeline.java:115)
	at org.apache.camel.processor.Pipeline.process(Pipeline.java:89)
	at
org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:68)
	at
org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:70)
	at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:41)
	at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:66)
	at
org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:47)
	at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:69)
	at
org.apache.camel.processor.BatchProcessor.processExchange(BatchProcessor.java:151)
	at
org.apache.camel.processor.BatchProcessor$BatchSender.sendExchanges(BatchProcessor.java:293)
	at
org.apache.camel.processor.BatchProcessor$BatchSender.run(BatchProcessor.java:238)


The solution I am thinking is to override the handleException method of the
Error handler which aggregator uses by default(I check the api when
org.apache.camel.processor.BatchProcessor$BatchSender.sendExchanges(BatchProcessor.java:293)
method is called, the catch block calls the handleException method which
actually handle the aggregator exception). But I am not able to find, how I
can set the error handler for my aggregator component.

Please suggest if this can be done, or if there is some better solution to
resolve the issue.

Thanks
Neeraj Mahajan
 




--
View this message in context: http://camel.465427.n5.nabble.com/Aggregator-not-propagating-exception-back-in-camel-version-1-6-2-tp5717629p5717676.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Aggregator not propagating exception back in camel version 1.6.2

Posted by Claus Ibsen <cl...@gmail.com>.
Camel 1.x is EOL and no longer supported at Apache.

in your custom aggregatorStrategy you should be able to get the caused
exception on the exchange. And decide what to do.

On Fri, Aug 17, 2012 at 6:05 PM, Neeraj Mahajan
<ne...@specsavers.com> wrote:
> I am calling a route from Aggregator using direct component once  aggregation
> is complete.
> When the called direct route throws any Exception I expect that aggregator
> *should not handle* that exception, but the problem I am facing is that the
> exception is being getting handled by the aggregator which i dont require.
>
> I am using camel *1.6.2 version* and i can't ugrade to newer versions.
> Following is code snippet i am using
>
> <route id="splitterRoute" errorHandlerRef="noErrorHandlerBuilder">
> <splitter>
>                 <xpath>/ord:orderSet/ord:orders/ord:order</xpath>
>                 <process ref="myProcessor" />
>                 <to uri="direct:aggregatorRoute" />
> </splitter>
> </route>
>
> <route id="aggregatorRoute" errorHandlerRef="noErrorHandlerBuilder">
>                         <from uri="direct:aggregatorRoute" />
>                         <aggregator strategyRef="aggregatorStrategy" >
>                                 <simple>header.JMSCorrelationID</simple>
>                                 <to uri="direct:responseGenerationRoute"/>
>                                 <completedPredicate>
>                                         <methodCall bean="aggregationCompletionStrategy"
> method="aggregationComplete" />
>                                 </completedPredicate>
>                         </aggregator>
> </route>
>
> <route id="responseGenerationRoute" errorHandlerRef="noErrorHandlerBuilder">
>                 <from uri="direct:responseGenerationRoute" />
>                 <process ref="responseGenerationProcessor" />
>                         <recipientList>
>                                 <header>responseDestination</header>
>                         </recipientList>
> </route>
>
> It will be helpfull, If someone can provide any direction on this.
>
> Thanks in Advance
> Neeraj
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Aggregator-not-propagating-exception-back-in-camel-version-1-6-2-tp5717629.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, fusenews
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen