camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stephen J <stephen.joy...@mclaneco.com>
Subject Re: AW: JMS Transactions - How To
Date Mon, 11 Feb 2008 17:18:25 GMT

Here's more information. It appears that the camel autowiring is not applying
the transaction policy to the router. 
When I manually set up everything with spring, executing the same code as in
my previous post I get the following(trimed) stack trace:
(executive summary: TransactionInterceptor catches the exception and doesn't
commit the transaction.)
----
INFO: Pre-instantiating singletons in
org.springframework.beans.factory.support.DefaultListableBeanFactory@29b029b0:
defining beans
[camelContext,mqseries,jmsConfig,transactionPolicy,transactionTemplate,jmsTransactionManager,myProxyConnectionFactory,mqConFactory,messageProcessor,testProcessor,msgConfig];
root of factory hierarchy
Feb 11, 2008 10:59:32 AM org.apache.camel.spring.spi.TransactionInterceptor
process
INFO: transaction begin
Process code here....
Message body: testing
Feb 11, 2008 10:59:32 AM org.apache.camel.processor.Logger log
SEVERE: On delivery attempt: 0 caught:
org.apache.camel.RuntimeCamelException: java.lang.Exception: Test exception.
org.apache.camel.RuntimeCamelException: java.lang.Exception: Test exception.
	at
org.apache.camel.spring.spi.TransactionInterceptor$1.doInTransactionWithoutResult(TransactionInterceptor.java:49)
	at
org.springframework.transaction.support.TransactionCallbackWithoutResult.doInTransaction(TransactionCallbackWithoutResult.java:33)
	at
org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:127)
	at
org.apache.camel.spring.spi.TransactionInterceptor.process(TransactionInterceptor.java:44)
	at
org.apache.camel.impl.converter.AsyncProcessorTypeConverter$ProcessorToAsynProcessorBridge.process(AsyncProcessorTypeConverter.java:44)
	at
org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:136)
	at
org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:86)
	at
org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:40)
	at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:44)
	at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:68)
	at
org.apache.camel.component.jms.EndpointMessageListener.onMessage(EndpointMessageListener.java:56)
	at
org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:510)
	at
org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:445)
	at
org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:414)
	at
org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:309)
	at
org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:234)
	at
org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:871)
	at
org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:818)
	at java.lang.Thread.run(Thread.java:803)
Caused by: java.lang.Exception: Test exception.
	at mqprinter.TestProc.process(TestProc.java:14)
	at
org.apache.camel.processor.DelegateProcessor.processNext(DelegateProcessor.java:47)
	at
org.apache.camel.spring.spi.TransactionInterceptor.access$000(TransactionInterceptor.java:33)
	at
org.apache.camel.spring.spi.TransactionInterceptor$1.doInTransactionWithoutResult(TransactionInterceptor.java:47)
	... 18 more

-----
And here's the spring code setting up the transactionized message
processing:
	springContext = new
ClassPathXmlApplicationContext("META-INF/spring/camel-context.xml");
	CamelContext camelContext =
SpringCamelContext.springCamelContext(springContext);
	camelContext.addRoutes(new SpringRouteBuilder() {	
	public void configure() throws Exception {
		Policy required = new
SpringTransactionPolicy((TransactionTemplate)springContext.getBean(
	                        "transactionTemplate")); 
		TestProc proc = (TestProc)springContext.getBean("testProcessor");
		from("mqseries:test").policy(required).process(proc);
	}
-----

It's probably just an incorrectly configured camelContext on my part, but
I'd be very appreciative if somebody could tell me how to get an xml route
to use the transaction policy I've specified.
Thanks to all.


Stephen J wrote:
> 
> Didn't help.
> Looking at the System.out from the Camel app when it tries to process the
> message I'd say the problem is that the transaction gets committed before
> the error processing happens. Here's a sample of the System.out where you
> see the commit message then the errors start dumping.
> 
> INFO: Pre-instantiating singletons in
> org.springframework.beans.factory.support.DefaultListableBeanFactory@33023302:
> defining beans
> [camelContext:beanPostProcessor,camelContext,mqseries,jmsConfig,transactionPolicy,transactionTemplate,jmsTransactionManager,myProxyConnectionFactory,mqConFactory,messageProcessor,testProcessor,msgConfig];
> root of factory hierarchy
> Feb 11, 2008 9:36:12 AM org.apache.camel.spring.spi.TransactionInterceptor
> process
> INFO: transaction begin
> Process code here....
> Message body: test
> Feb 11, 2008 9:36:12 AM org.apache.camel.spring.spi.TransactionInterceptor
> process
> INFO: transaction commit
> Feb 11, 2008 9:36:13 AM org.apache.camel.processor.Logger log
> SEVERE: On delivery attempt: 0 caught: java.lang.Exception: Test
> exception.
> java.lang.Exception: Test exception. at
> mqprinter.TestProc.process(TestProc.java:14) at
> org.apache.camel.impl.converter.AsyncProcessorTypeConverter$ProcessorToAsynProcessorBridge.process(AsyncProcessorTypeConverter.java:44)
> 	at
> org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:136)
> 	at
> org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:86)
> 	at org.apache.camel.processor.Pipeline.process(Pipeline.java:103)
> 	at org.apache.camel.processor.Pipeline.process(Pipeline.java:87)
> 	at
> org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:40)
> 	at
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:44)
> 	at
> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:68)
> ------
> Here's how I have my camelContext configured
> <camelContext xmlns="http://activemq.apache.org/camel/schema/spring" >
>    <route>
>    	<from uri="mqseries:test" />
>    	<policy ref="transactionPolicy" />
>    	<process ref="testProcessor" />
>    </route>
>   </camelContext> 
> ------
> Here's the testProcess code:
> public void process(Exchange exch) throws Exception {
>   System.out.println("Process code here....");
>   System.out.println("Message body: " + exch.getIn().getBody());
>   throw new Exception("Test exception.");
> }
> ------
> 
> 

-- 
View this message in context: http://www.nabble.com/JMS-Transactions---How-To-tp15168958s22882p15415954.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Mime
View raw message