You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by "Charles Moulliard (JIRA)" <ji...@apache.org> on 2009/09/01 09:45:22 UTC

[jira] Issue Comment Edited: (CAMEL-1965) onException does not work correctly when used in a transacted route and exception is not send to the bean component called

    [ https://issues.apache.org/activemq/browse/CAMEL-1965?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=53935#action_53935 ] 

Charles Moulliard edited comment on CAMEL-1965 at 9/1/09 12:44 AM:
-------------------------------------------------------------------

Is there a better command than "code" to format info in the wiki ?

Camel Version used : 2.0 and now 2.1-SNAPSHOT

Endpoints definition :

{code}
queueReportingEndpoint = uriQueueReporting=queuingservice:x3s:reporting (remark : queuingservice --> corresponds to activemq service packaged as separate osgi bundle)
queueRequestEndpoint= uriQueueRequest=queuingservice:x3s:request
fileClientEndpoint = uriFileClient=file://d:/temp/data/oinp/?delay=15000&move=d:/temp/data/oinp/backup/${date:now:yyyyMMdd}/${file:name.noext}.bak&moveFailed=d:/temp/data/oinp/error//${date:now:yyyyMMdd}/${file:name.noext}.error

<!-- Defintion of the Camel - ActiveMq Spring config file -->
<beans xmlns="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:osgi="http://www.springframework.org/schema/osgi"
  xsi:schemaLocation="http://www.springframework.org/schema/beans
                      http://www.springframework.org/schema/beans/spring-beans.xsd
                      http://www.springframework.org/schema/osgi
                      http://www.springframework.org/schema/osgi/spring-osgi.xsd
                      http://camel.apache.org/schema/spring
                      http://camel.apache.org/schema/spring/camel-spring.xsd">
      
    <bean id="active-mq" class="org.apache.activemq.camel.component.ActiveMQComponent">
    	<property name="transacted" value="true"/>
    	<property name="connectionFactory">
    		<osgi:reference interface="javax.jms.ConnectionFactory"/>
    	</property>
        <property name="transactionManager">
			<osgi:reference interface="org.springframework.transaction.PlatformTransactionManager"/>
		</property>
		<!-- <property name="transferExchange" value="true"/> -->
    </bean>

    <osgi:service id="osgiqueuingservice" ref="active-mq" interface="org.apache.camel.Component"/>
		       
</beans>

-----------------------------------
For Camel configuration

<!-- OSGI reference of the service used  -->
<!-- Queuing service -->
<osgi:reference id="queuingservice" interface="org.apache.camel.Component" />

<!-- TransactionErrorHandler -->
	<bean id="txErrorHandlerReqNew" class="org.apache.camel.spring.spi.TransactionErrorHandlerBuilder">
        <property name="springTransactionPolicy" ref="PROPAGATION_REQUIRED_NEW"/>
</bean>

<!-- Transaction Policy -->
<bean id="PROPAGATION_REQUIRED_NEW" class="org.apache.camel.spring.spi.SpringTransactionPolicy">
        <property name="transactionManager">
			<osgi:reference>
				<osgi:interfaces>
					<value>org.springframework.orm.hibernate3.HibernateTransactionManager</value>
				</osgi:interfaces>
			</osgi:reference>
  		</property>
  		<property name="propagationBehaviorName" value="PROPAGATION_REQUIRES_NEW"/>
</bean> 

<!-- Full route -->
	<camel:camelContext id="InToOut" trace="true"	xmlns="http://camel.apache.org/schema/osgi">
		<camel:route errorHandlerRef="txErrorHandlerReqNew">
			<camel:from ref="fileClientEndpoint" />
			<camel:transacted ref="PROPAGATION_REQUIRED_NEW" />
			
		    <camel:onException>
	        	<camel:exception>com.xpectis.x3s.exception.X3SClientException</camel:exception>
				<camel:bean ref="serviceHelper" method="processException" />
				<camel:to ref="queueReportingEndpoint" />
            </camel:onException>
			
			<camel:onException>
				<camel:exception>java.lang.Exception</camel:exception>
				<camel:to uri="log:com.xpectis.x3s?level=INFO&amp;multiline=true&amp;showException=true&amp;showCaughtException=true&amp;showStackTrace=true" />
				<camel:rollback/>
		    </camel:onException>

				<camel:setHeader headerName="origin">
					<camel:constant>file</camel:constant>
				</camel:setHeader>

				<!-- Set Message type header with the name of the parent folder -->
				<camel:bean ref="serviceHelper" method="getParentFolderName" />

				<camel:convertBodyTo type="java.lang.String" />
			
				<!-- Call the requestService to save the request -->
				<camel:bean ref="serviceHelper" method="createRequest" />
				
                                <!-- ERROR GENERATED FOR TESTING PURPOSE -->
				<camel:bean ref="serviceHelper" method="generateX3SClientException" />  
				<!-- <camel:bean ref="serviceHelper" method="generateException" /> -->	
				
				<camel:to ref="queueRequestEndpoint" />
		</camel:route>
{code}




      was (Author: cmoulliard):
    Is there a better command than {code} to format info in the wiki ?

Camel Version used : 2.0 and now 2.1-SNAPSHOT

Endpoints definition :

{code}
queueReportingEndpoint = uriQueueReporting=queuingservice:x3s:reporting (remark : queuingservice --> corresponds to activemq service packaged as separate osgi bundle)
queueRequestEndpoint= uriQueueRequest=queuingservice:x3s:request
fileClientEndpoint = uriFileClient=file://d:/temp/data/oinp/?delay=15000&move=d:/temp/data/oinp/backup/${date:now:yyyyMMdd}/${file:name.noext}.bak&moveFailed=d:/temp/data/oinp/error//${date:now:yyyyMMdd}/${file:name.noext}.error

<!-- Defintion of the Camel - ActiveMq Spring config file -->
<beans xmlns="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:osgi="http://www.springframework.org/schema/osgi"
  xsi:schemaLocation="http://www.springframework.org/schema/beans
                      http://www.springframework.org/schema/beans/spring-beans.xsd
                      http://www.springframework.org/schema/osgi
                      http://www.springframework.org/schema/osgi/spring-osgi.xsd
                      http://camel.apache.org/schema/spring
                      http://camel.apache.org/schema/spring/camel-spring.xsd">
      
    <bean id="active-mq" class="org.apache.activemq.camel.component.ActiveMQComponent">
    	<property name="transacted" value="true"/>
    	<property name="connectionFactory">
    		<osgi:reference interface="javax.jms.ConnectionFactory"/>
    	</property>
        <property name="transactionManager">
			<osgi:reference interface="org.springframework.transaction.PlatformTransactionManager"/>
		</property>
		<!-- <property name="transferExchange" value="true"/> -->
    </bean>

    <osgi:service id="osgiqueuingservice" ref="active-mq" interface="org.apache.camel.Component"/>
		       
</beans>

-----------------------------------
For Camel configuration

<!-- OSGI reference of the service used  -->
<!-- Queuing service -->
<osgi:reference id="queuingservice" interface="org.apache.camel.Component" />

<!-- TransactionErrorHandler -->
	<bean id="txErrorHandlerReqNew" class="org.apache.camel.spring.spi.TransactionErrorHandlerBuilder">
        <property name="springTransactionPolicy" ref="PROPAGATION_REQUIRED_NEW"/>
</bean>

<!-- Transaction Policy -->
<bean id="PROPAGATION_REQUIRED_NEW" class="org.apache.camel.spring.spi.SpringTransactionPolicy">
        <property name="transactionManager">
			<osgi:reference>
				<osgi:interfaces>
					<value>org.springframework.orm.hibernate3.HibernateTransactionManager</value>
				</osgi:interfaces>
			</osgi:reference>
  		</property>
  		<property name="propagationBehaviorName" value="PROPAGATION_REQUIRES_NEW"/>
</bean> 

<!-- Full route -->
	<camel:camelContext id="InToOut" trace="true"	xmlns="http://camel.apache.org/schema/osgi">
		<camel:route errorHandlerRef="txErrorHandlerReqNew">
			<camel:from ref="fileClientEndpoint" />
			<camel:transacted ref="PROPAGATION_REQUIRED_NEW" />
			
		    <camel:onException>
	        	<camel:exception>com.xpectis.x3s.exception.X3SClientException</camel:exception>
				<camel:bean ref="serviceHelper" method="processException" />
				<camel:to ref="queueReportingEndpoint" />
            </camel:onException>
			
			<camel:onException>
				<camel:exception>java.lang.Exception</camel:exception>
				<camel:to uri="log:com.xpectis.x3s?level=INFO&amp;multiline=true&amp;showException=true&amp;showCaughtException=true&amp;showStackTrace=true" />
				<camel:rollback/>
		    </camel:onException>

				<camel:setHeader headerName="origin">
					<camel:constant>file</camel:constant>
				</camel:setHeader>

				<!-- Set Message type header with the name of the parent folder -->
				<camel:bean ref="serviceHelper" method="getParentFolderName" />

				<camel:convertBodyTo type="java.lang.String" />
			
				<!-- Call the requestService to save the request -->
				<camel:bean ref="serviceHelper" method="createRequest" />
				
                                <!-- ERROR GENERATED FOR TESTING PURPOSE -->
				<camel:bean ref="serviceHelper" method="generateX3SClientException" />  
				<!-- <camel:bean ref="serviceHelper" method="generateException" /> -->	
				
				<camel:to ref="queueRequestEndpoint" />
		</camel:route>
{code}



  
> onException does not work correctly when used in a transacted route and exception is not send to the bean component called
> --------------------------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-1965
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-1965
>             Project: Apache Camel
>          Issue Type: Bug
>    Affects Versions: 2.0.0
>            Reporter: Charles Moulliard
>
> Hi,
> When onException is used within a transacted route, it does not work. With the following route, the onException process does not propagate information to the from endpoint (in my case : file component). So, when X3Sexception occurs, the bean component is called where record is created in an Audit table, error message is put in a reporting queue BUT the file could not be renamed and move to temp directory. In consequence, the file is reprocessed continuously !!!!!
> {code}
> Route
> <camel:route errorHandlerRef="txErrorHandlerReqNew">
> 	<camel:from ref="fileClientEndpoint" />
> 	<camel:transacted ref="PROPAGATION_REQUIRED_NEW" />
> 		
>          <camel:onException>
> 	       	<camel:exception>com.xpectis.x3s.exception.X3SClientException</camel:exception>
> 		<camel:bean ref="serviceHelper" method="processException" />
> 		<camel:to ref="queueReportingEndpoint" />
>            </camel:onException>
> 	
> 	<camel:onException>
> 		<camel:exception>java.lang.Exception</camel:exception>
> 		<camel:to uri="log:com.xpectis.x3s?level=INFO&amp;multiline=true&amp;showException=true&amp;showCaughtException=true&amp;showStackTrace=true" />
> 		<camel:rollback/>
>     </camel:onException>
> {code}
> {code}
> Log
> 16:51:12,896 | INFO  | 9: FileComponent | TraceInterceptor                 | rg.apache.camel.processor.Logger   88 | ID-dell-charles-2415-1251709696459-0-85 >>> from(file://d:/temp/data/oinp/?delay=15000&move=d%3A%2Ftemp%2Fdata%2Foinp%2Fbackup%2F%24%7Bdate%3Anow%3AyyyyMMdd%7D%2F%24%7Bfile%3Aname.noext%7D.bak&moveFailed=d%3A%2Ftemp%2Fdata%2Foinp%2Ferror%2F%2F%24%7Bdate%3Anow%3AyyyyMMdd%7D%2F%24%7Bfile%3Aname.noext%7D.error) --> ref:PROPAGATION_REQUIRED_NEW, Pattern:InOnly, Headers:{CamelFileNameOnly=OINP_Example.csv, CamelFileLastModified=Mon Jul 27 16:33:12 CEST 2009, CamelFileAbsolute=true, CamelFileLength=892, CamelFileName=OINP_Example.csv, CamelFileParent=d:\temp\data\oinp, CamelFilePath=d:\temp\data\oinp\OINP_Example.csv, CamelFileRelativePath=d:\temp\data\oinp\OINP_Example.csv, CamelFileAbsolutePath=d:\temp\data\oinp\OINP_Example.csv}, BodyType:org.apache.camel.component.file.GenericFile, Body:ORD_REF_ID, ...
> 16:51:12,912 | INFO  | 9: FileComponent | TraceInterceptor                 | rg.apache.camel.processor.Logger   88 | ID-dell-charles-2415-1251709696459-0-85 >>> ref:PROPAGATION_REQUIRED_NEW --> ref:PROPAGATION_REQUIRED_NEW, Pattern:InOnly, Headers:{CamelFileNameOnly=OINP_Example.csv, CamelFileLastModified=Mon Jul 27 16:33:12 CEST 2009, CamelFileAbsolute=true, CamelFileLength=892, CamelFileName=OINP_Example.csv, CamelFileParent=d:\temp\data\oinp, CamelFilePath=d:\temp\data\oinp\OINP_Example.csv, CamelFileRelativePath=d:\temp\data\oinp\OINP_Example.csv, CamelFileAbsolutePath=d:\temp\data\oinp\OINP_Example.csv}, BodyType:org.apache.camel.component.file.GenericFile, Body:ORD_REF_ID,...
> 16:51:12,912 | INFO  | 9: FileComponent | TraceInterceptor                 | rg.apache.camel.processor.Logger   88 | ID-dell-charles-2415-1251709696459-0-85 >>> ref:PROPAGATION_REQUIRED_NEW --> OnException, Pattern:InOnly, Headers:{CamelFileNameOnly=OINP_Example.csv, CamelFileLastModified=Mon Jul 27 16:33:12 CEST 2009, CamelFileAbsolute=true, CamelFileLength=892, CamelFileName=OINP_Example.csv, CamelFileParent=d:\temp\data\oinp, CamelFilePath=d:\temp\data\oinp\OINP_Example.csv, CamelFileRelativePath=d:\temp\data\oinp\OINP_Example.csv, CamelFileAbsolutePath=d:\temp\data\oinp\OINP_Example.csv}, BodyType:org.apache.camel.component.file.GenericFile, Body:ORD_REF_ID,...
> 16:51:12,928 | INFO  | 9: FileComponent | TraceInterceptor                 | rg.apache.camel.processor.Logger   88 | ID-dell-charles-2415-1251709696459-0-85 >>> OnException -->, Pattern:InOnly, Headers:{CamelFileNameOnly=OINP_Example.csv, CamelFileLastModified=Mon Jul 27 16:33:12 CEST 2009, CamelFileAbsolute=true, CamelFileLength=892, CamelFileName=OINP_Example.csv, CamelFileParent=d:\temp\data\oinp, CamelFilePath=d:\temp\data\oinp\OINP_Example.csv, CamelFileRelativePath=d:\temp\data\oinp\OINP_Example.csv, CamelFileAbsolutePath=d:\temp\data\oinp\OINP_Example.csv}, BodyType:org.apache.camel.component.file.GenericFile, Body:ORD_REF_ID,...
> 16:51:12,928 | INFO  | 9: FileComponent | ServiceHelper                    | ctis.x3s.core.util.ServiceHelper 1033 | ###### processException ######
> 16:51:12,928 | INFO  | 9: FileComponent | ServiceHelper                    | ctis.x3s.core.util.ServiceHelper 1046 | #### Exception received was null so create a dummy exception !
> 16:51:12,928 | INFO  | 9: FileComponent | ServiceHelper                    | ctis.x3s.core.util.ServiceHelper 1054 | >>>processException AUDIT:E9998:Error:ERR
> 16:51:12,975 | INFO  | 9: FileComponent | TraceInterceptor                 | rg.apache.camel.processor.Logger   88 | ID-dell-charles-2415-1251709696459-0-85 >>>  --> queuingservice://x3s:reporting, Pattern:InOnly, Headers:{CamelFileLastModified=Mon Jul 27 16:33:12 CEST 2009, CamelFilePath=d:\temp\data\oinp\OINP_Example.csv, CamelFileLength=892, CamelFileAbsolutePath=d:\temp\data\oinp\OINP_Example.csv, CamelBeanMethodName=null, CamelFileNameOnly=OINP_Example.csv, CamelFileAbsolute=true, CamelBeanMultiParameterArray=false, CamelFileName=OINP_Example.csv, CamelFileRelativePath=d:\temp\data\oinp\OINP_Example.csv, CamelFileParent=d:\temp\data\oinp}, BodyType:org.apache.camel.component.file.GenericFile, Body:ORD_REF_ID,
> 16:51:13,068 | INFO  | 9: FileComponent | TraceInterceptor                 | rg.apache.camel.processor.Logger   88 | ID-dell-charles-2415-1251709696459-0-85 >>> queuingservice://x3s:reporting --> ref:PROPAGATION_REQUIRED_NEW, Pattern:InOnly, Headers:{CamelFileAbsolute=true, CamelFileLength=892, CamelBeanMethodName=null, CamelFileName=OINP_Example.csv, CamelFileLastModified=Mon Jul 27 16:33:12 CEST 2009, CamelFileAbsolutePath=d:\temp\data\oinp\OINP_Example.csv, CamelFileRelativePath=d:\temp\data\oinp\OINP_Example.csv, CamelFileNameOnly=OINP_Example.csv, CamelBeanMultiParameterArray=false, CamelFilePath=d:\temp\data\oinp\OINP_Example.csv, CamelFileParent=d:\temp\data\oinp}, BodyType:org.apache.camel.component.file.GenericFile, Body:ORD_REF_ID,...
> 16:51:13,068 | INFO  | 9: FileComponent | TraceInterceptor                 | rg.apache.camel.processor.Logger   88 | ID-dell-charles-2415-1251709696459-0-85 >>> ref:PROPAGATION_REQUIRED_NEW --> OnException, Pattern:InOnly, Headers:{CamelFileAbsolute=true, CamelFileLength=892, CamelBeanMethodName=null, CamelFileName=OINP_Example.csv, CamelFileLastModified=Mon Jul 27 16:33:12 CEST 2009, CamelFileAbsolutePath=d:\temp\data\oinp\OINP_Example.csv, CamelFileRelativePath=d:\temp\data\oinp\OINP_Example.csv, CamelFileNameOnly=OINP_Example.csv, CamelBeanMultiParameterArray=false, CamelFilePath=d:\temp\data\oinp\OINP_Example.csv, CamelFileParent=d:\temp\data\oinp}, BodyType:org.apache.camel.component.file.GenericFile, Body:ORD_REF_ID,...
> 16:51:13,084 | INFO  | 9: FileComponent | TraceInterceptor                 | rg.apache.camel.processor.Logger   88 | ID-dell-charles-2415-1251709696459-0-85 >>> OnException --> log://com.xpectis.x3s?level=INFO&multiline=true&showCaughtException=true&showException=true&showStackTrace=true, Pattern:InOnly, Headers:{CamelFileAbsolute=true, CamelFileLength=892, CamelBeanMethodName=null, CamelFileName=OINP_Example.csv, CamelFileLastModified=Mon Jul 27 16:33:12 CEST 2009, CamelFileAbsolutePath=d:\temp\data\oinp\OINP_Example.csv, CamelFileRelativePath=d:\temp\data\oinp\OINP_Example.csv, CamelFileNameOnly=OINP_Example.csv, CamelBeanMultiParameterArray=false, CamelFilePath=d:\temp\data\oinp\OINP_Example.csv, CamelFileParent=d:\temp\data\oinp}, BodyType:org.apache.camel.component.file.GenericFile, Body:ORD_REF_ID,...
> 16:51:13,084 | INFO  | 9: FileComponent | x3s                              | rg.apache.camel.processor.Logger   88 | Exchange[
> , BodyType:org.apache.camel.component.file.GenericFile
> , Body:ORD_REF_ID,...
> 16:51:13,084 | INFO  | 9: FileComponent | TraceInterceptor                 | rg.apache.camel.processor.Logger   88 | ID-dell-charles-2415-1251709696459-0-85 >>> log://com.xpectis.x3s?level=INFO&multiline=true&showCaughtException=true&showException=true&showStackTrace=true --> Rollback, Pattern:InOnly, Headers:{CamelFileName=OINP_Example.csv, CamelBeanMethodName=null, CamelBeanMultiParameterArray=false, CamelFileParent=d:\temp\data\oinp, CamelFileNameOnly=OINP_Example.csv, CamelFileAbsolutePath=d:\temp\data\oinp\OINP_Example.csv, CamelFilePath=d:\temp\data\oinp\OINP_Example.csv, CamelFileRelativePath=d:\temp\data\oinp\OINP_Example.csv, CamelFileLastModified=Mon Jul 27 16:33:12 CEST 2009, CamelFileAbsolute=true, CamelFileLength=892}, BodyType:org.apache.camel.component.file.GenericFile, Body:ORD_REF_ID,...
> 16:51:13,100 | ERROR | 9: FileComponent | GenericFileOnCompletion          | rg.apache.camel.processor.Logger  202 | org.apache.camel.RollbackExchangeException: Intended rollback on the exchange: Exchange[GenericFileMessage with file: GenericFile[d:\temp\data\oinp\OINP_Example.csv]]
> 16:51:13,100 | WARN  | 9: FileComponent | GenericFileOnCompletion          | ent.file.GenericFileOnCompletion  142 | Rollback file strategy: org.apache.camel.component.file.strategy.GenericFileRenameProcessStrategy@29e26 for file: GenericFile[d:\temp\data\oinp\OINP_Example.csv]
> 16:51:13,100 | ERROR | 9: FileComponent | GenericFileOnCompletion          | rg.apache.camel.processor.Logger  248 | Cannot rename file: GenericFile[d:\temp\data\oinp\OINP_Example.csv] to: GenericFile[d:\temp\data\oinp\error\\20090831\OINP_Example.error]
> org.apache.camel.component.file.GenericFileOperationFailedException: Cannot rename file: GenericFile[d:\temp\data\oinp\OINP_Example.csv] to: GenericFile[d:\temp\data\oinp\error\\20090831\OINP_Example.error]
> 	at org.apache.camel.component.file.strategy.GenericFileRenameProcessStrategy.renameFile(GenericFileRenameProcessStrategy.java:96)
> 	at org.apache.camel.component.file.strategy.GenericFileRenameProcessStrategy.rollback(GenericFileRenameProcessStrategy.java:61)
> 	at org.apache.camel.component.file.GenericFileOnCompletion.processStrategyRollback(GenericFileOnCompletion.java:145)
> 	at org.apache.camel.component.file.GenericFileOnCompletion.onCompletion(GenericFileOnCompletion.java:95)
> 	at org.apache.camel.component.file.GenericFileOnCompletion.onFailure(GenericFileOnCompletion.java:58)
> 	at org.apache.camel.impl.DefaultUnitOfWork.done(DefaultUnitOfWork.java:126)
> {code}
> REMARK : 
> - Exception object is not received by the bean component
> but everything works fine if the route is defined like this 
> {code}
> 		<camel:route>
> 			<camel:from ref="fileClientEndpoint" />
> 		    <camel:onException>
> 	        	<camel:exception>com.xpectis.x3s.exception.X3SClientException</camel:exception>
> 				<camel:bean ref="serviceHelper" method="processException" />
> 				<camel:to ref="queueReportingEndpoint" />
>             </camel:onException>
> 			
> 			<camel:onException>
> 				<camel:exception>java.lang.Exception</camel:exception>
> 				<camel:to uri="log:com.xpectis.x3s?level=INFO&amp;multiline=true&amp;showException=true&amp;showCaughtException=true&amp;showStackTrace=true" />
> 		    </camel:onException>
> {code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.