camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jakub Korab <jakub.ko...@ameliant.com>
Subject Re: AggregatinStrategy on split never stop
Date Fri, 11 Dec 2015 14:49:02 GMT
To handle exceptions within a split, your AggregationStrategy needs to 
be written in such a way that it deals with Exceptions. See the 
following for an example:

https://github.com/CamelCookbook/camel-cookbook-examples/blob/master/camel-cookbook-routing/src/main/java/org/camelcookbook/routing/multicast/ExceptionHandlingAggregationStrategy.java

If you don't, the splitting process will complete anyway, but the 
exception will be thrown afterwards - never reaching the next processor 
(in your case, "Check_New_Record"). See the documentation about 
"stopOnException" here:

     https://camel.apache.org/splitter.html

Jakub

On 11/12/15 08:27, Scisci wrote:
> hi,
> sorry for the delayed response.
> I'm using camel version 2.6.0 and spring version 4.1.6.RELEASE.
> This one of the routes
>
> <camelContext id="XXX"
> 	  	xmlns="http://camel.apache.org/schema/spring"
> 	  	xmlns:ag_01="http://www.my.it/Accpos"
> 	  	
> 	  	>
> 	  	
>      	<propertyPlaceholder id="placeholder"
> location="classpath:file.properties"/>
>      	
>          <route id="Accpos">
> 			<from
> uri="file:{{Path_In}}?fileName={{File_Name_Accpos}}&amp;readLock=changed&amp;readLockTimeout=10000&amp;readLockCheckInterval=5000&amp;move={{Backup}}"/>
>   			<doTry>
>        			<to uri="validator:classpath:Accpos.xsd"/>
>        			<log message="Reciving ${file:name}"/>
>        			<setHeader headerName="Tipo_Fondo"><xpath
> resultType="java.lang.String">/ag_01:Accpos/ag_01:Tipo_Fondo/text()</xpath></setHeader>
>        			<log message="Tipo_Fondo : ${header.Tipo_Fondo}"/>
>        			<setHeader headerName="Data_Giro"><xpath
> resultType="java.lang.String">/ag_01:Accpos/ag_01:Data_Giro/text()</xpath></setHeader>
>        			<log message="Data_Giro : ${header.Data_Giro}"/>
>        			<setHeader headerName="Numero_Record_Inviati"><xpath
> resultType="java.lang.String">/ag_01:Accpos/ag_01:Items/@count</xpath></setHeader>
>        			<log message="Numero_Record_Inviati :
> ${header.Numero_Record_Inviati}"/>
>        			<setHeader
> headerName="Tabella"><simple>${file:name}</simple></setHeader>
>        			<log message="Tabella : ${header.Tabella}"/>
>        			<setHeader headerName="Numero_Items"><simple>0</simple></setHeader>
>        			<log message="Numero_Items : ${header.Numero_Items}"/>
>        			<process ref="Clean_Tables"/>
> 				<split strategyRef="Item_Aggregator" streaming="true">
> 					<xtokenize>/ag_01:Accpos/ag_01:Items/ag_01:Item</xtokenize>
> 					<to uri="direct:Convert_Accpos"/>
>          		</split>
>          		<process ref="Check_New_Record"/>
>          		<to uri="direct:Mail_Info_Loading"/>
>    				<doCatch>
>          			<exception>org.apache.camel.ValidationException</exception>
> 			        <setHeader headerName="subject">
> 			          <simple>ERRORE - validazione - ACCPOS</simple>
> 			        </setHeader>
> 			        <setBody>
> 			          <simple>Errore nella validazione \r \n
> ${exception.message}</simple>
> 			        </setBody>
> 			        <to
> uri="smtp://{{Mail_Server}}?from={{Sender}}&amp;to={{Receivers_Error}}"/>
> 			    </doCatch>
>      		</doTry>
>          </route>
>          <route id="Convert_Accpos"
> errorHandlerRef="myDeadLetterErrorHandler_Accpos">
>          	<from uri="direct:Convert_Accpos"/>
>          	<unmarshal>
> 				<jaxb contextPath="it.my.Risk_Files.Accpos"
> partClass="it.my.Risk_Files.Accpos.ItemType" ignoreJAXBElement="true"/>
> 			</unmarshal>
> 			<convertBodyTo type="it.my.Risk_Files.Accpos.Accpos"/>
> 			<to uri="jpa:it.my.Risk_Files.Accpos.Accpos?usePersist=true"/>
>      	</route>
> ....
>
> <bean id="myDeadLetterErrorHandler_Accpos"
> class="org.apache.camel.builder.DeadLetterChannelBuilder">
>      	<property name="deadLetterUri"
> value="jpa:it.my.Risk_Files.Accpos.Accpos_Error"/>
> 	</bean>
>
> if the last split throw an error, for example primary key violation, never
> return after the deadletter error handler and don't execute process
> Check_New_Record.
>
> Thanks
> Mirko
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/AggregatinStrategy-on-split-never-stop-tp5773905p5774985.html
> Sent from the Camel - Users mailing list archive at Nabble.com.


Mime
View raw message