You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by regvito <re...@transcentra.com> on 2012/02/03 01:08:34 UTC

problem propagating exceptions with splitter and aggregator

I have a consumer file endpoint where I want it to send the file to an error
folder using moveFailed
if there are any errors processing the file.

I can get a route working that has a splitter where it calls a bean to
process each row in the file.
When that throws an exception, the consumer file endpoint works as expected
and moves the file
being processing to the error folder. Here is a simplified route of this:
    <route>
      <from uri="file:src/data/?move=.done&amp;moveFailed=.error"/>
      <split streaming="true" shareUnitOfWork="true">
        <tokenize token="\n"/>
	        <bean ref="myTransform" />
      </split>
      <to uri="log:ExampleRouter"/>
    </route>

However, when I add an aggregator within the splitter and the bean throws an
exception,
it doesn't work as exptected.  It looks like the exception isn't being
propagated somehow
to enable that file being processed to be sent to the error folder.
Here is that simplified route:

    <route>
      <from uri="file:src/data/?move=.done&amp;moveFailed=.error"/>
      <split streaming="true" shareUnitOfWork="true">
        <tokenize token="\n"/>
        <aggregate strategyRef="aggregatorStrategy" 
	                         completionSize="1000" >
  				<correlationExpression>
	             <simple>1</simple> 
	          </correlationExpression>
              
              
              <completionPredicate>
	          	<simple>${property.CamelSplitComplete}</simple> 
              </completionPredicate>
              	    
	        <bean ref="myTransform" />
	    
	    </aggregate>
	                         
      </split>
      <to uri="log:ExampleRouter"/>
    </route>

Any ideas on how I can move the file being processed into the error folder
when 
my bean throws an exception with a route like above with a spiltter and
aggregator?  

--
View this message in context: http://camel.465427.n5.nabble.com/problem-propagating-exceptions-with-splitter-and-aggregator-tp5452376p5452376.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: problem propagating exceptions with splitter and aggregator

Posted by Claus Ibsen <cl...@gmail.com>.
The splitter has aggregator built-in, use that instead, eg there is a
strategyRef option on <splitter>



On Fri, Feb 3, 2012 at 6:49 PM, regvito <re...@transcentra.com> wrote:
> As shown above, I already have shareUnitOfWork="true".
> The splitter works fine when my bean is called from within it
> and throws an error.  The file gets moved to the error folder.
> But when I add an aggregator within the splitter and the bean
> throws an exception, it doesn't move the file to the error folder.
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/problem-propagating-exceptions-with-splitter-and-aggregator-tp5452376p5454625.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.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Re: problem propagating exceptions with splitter and aggregator

Posted by regvito <re...@transcentra.com>.
As shown above, I already have shareUnitOfWork="true".
The splitter works fine when my bean is called from within it
and throws an error.  The file gets moved to the error folder.
But when I add an aggregator within the splitter and the bean
throws an exception, it doesn't move the file to the error folder.

--
View this message in context: http://camel.465427.n5.nabble.com/problem-propagating-exceptions-with-splitter-and-aggregator-tp5452376p5454625.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: problem propagating exceptions with splitter and aggregator

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Use the shareUnitOfWork option as documented on the Splitter EIP page
http://camel.apache.org/splitter

On Fri, Feb 3, 2012 at 1:08 AM, regvito <re...@transcentra.com> wrote:
> I have a consumer file endpoint where I want it to send the file to an error
> folder using moveFailed
> if there are any errors processing the file.
>
> I can get a route working that has a splitter where it calls a bean to
> process each row in the file.
> When that throws an exception, the consumer file endpoint works as expected
> and moves the file
> being processing to the error folder. Here is a simplified route of this:
>    <route>
>      <from uri="file:src/data/?move=.done&amp;moveFailed=.error"/>
>      <split streaming="true" shareUnitOfWork="true">
>        <tokenize token="\n"/>
>                <bean ref="myTransform" />
>      </split>
>      <to uri="log:ExampleRouter"/>
>    </route>
>
> However, when I add an aggregator within the splitter and the bean throws an
> exception,
> it doesn't work as exptected.  It looks like the exception isn't being
> propagated somehow
> to enable that file being processed to be sent to the error folder.
> Here is that simplified route:
>
>    <route>
>      <from uri="file:src/data/?move=.done&amp;moveFailed=.error"/>
>      <split streaming="true" shareUnitOfWork="true">
>        <tokenize token="\n"/>
>        <aggregate strategyRef="aggregatorStrategy"
>                                 completionSize="1000" >
>                                <correlationExpression>
>                     <simple>1</simple>
>                  </correlationExpression>
>
>
>              <completionPredicate>
>                        <simple>${property.CamelSplitComplete}</simple>
>              </completionPredicate>
>
>                <bean ref="myTransform" />
>
>            </aggregate>
>
>      </split>
>      <to uri="log:ExampleRouter"/>
>    </route>
>
> Any ideas on how I can move the file being processed into the error folder
> when
> my bean throws an exception with a route like above with a spiltter and
> aggregator?
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/problem-propagating-exceptions-with-splitter-and-aggregator-tp5452376p5452376.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.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/