You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by priya <jo...@gmail.com> on 2012/06/15 10:59:07 UTC

Exception not propagated in Splitter-Aggregator EIP

I have route like this:

errorHandler(transactionErrorHandler().maximumRedeliveries(0));

from("seda:fileInput")
  .onException(IllegalArgumentException.class).maximumRedeliveries(0)	
    .log( idExpr + "Error occured during processing of Data")
  .end()
.transacted()
.split(myFileSplitterExp(inFile))
   .streaming()
  .stopOnException()
  .bean(myBean)
.aggregate(header(HeaderConstant.JOB_ID), new
MyStringBuilderAggregationStrategy())		
.completionSize(10)
.completionTimeout(2000)
.completionPredicate(
header(Exchange.SPLIT_COMPLETE).isEqualTo(Boolean.TRUE))
.to("direct:updateDB");



with aggregationStrategy defined as:

private class MyStringBuilderAggregationStrategy implements
AggregationStrategy {
	@Override
		public Exchange aggregate(final Exchange oldExchange, final Exchange
newExchange) {
			final DataSet newBody = newExchange.getIn().getBody(DataSet.class);
			List <DataSet>list = null;
		if(newExchange != null && newExchange.getException()!=null )
		{
		 	log.info("exception caught***" + newExchange.getException());
		}else if (oldExchange != null && oldExchange.getException()!= null)
		{
		 	log.info("exception caught in oldExc***" + oldExchange.getException());
		}else
			log.info("no exception ****");
	
			
			if (oldExchange == null) {
				list = new ArrayList<DataSet>();
				list.add(newBody);
				newExchange.getIn().setBody(list);
				return newExchange;
			} else {
				list = oldExchange.getIn().getBody(List.class);
				list.add(newBody);
				return oldExchange;
			}}}
The problem is We are unable to get hold of exception in 
MyStringBuilderAggregationStrategy, in case some exception occurs in myBean
for some invalid record.

Exchange.getEception() is null as against the example in Chpater 8 of the
book.

Also with stopOnException() though we are able to stop further processing of
Exchange messages and rollback  the Batch records inserted before the
errornous Exchange using errorHandler(transactionErrorHandler()).But, since
we are unable to catch the exception on this errornous Batch(subExchange of
parent exchange) we are unable to dump the records which were aggregated
before the error of the same errornous Batch and it goes for further
processing to ("direct:updateDB") endpoint which is DB insertion.



--
View this message in context: http://camel.465427.n5.nabble.com/Exception-not-propagated-in-Splitter-Aggregator-EIP-tp5714533.html
Sent from the Camel - Users mailing list archive at Nabble.com.