如何为特定的驼峰路线设置事务超时?

时间:2016-11-18 01:39:06

标签: spring transactions apache-camel wildfly jta

我是一条骆驼路线需要相当长的时间才能完成,但最终失败的原因是:

org.springframework.transaction.UnexpectedRollbackException: JTA transaction already rolled back (probably due to a timeout)
              at org.springframework.transaction.jta.JtaTransactionManager.doCommit(JtaTransactionManager.java:1019)
              at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:757)
              at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:726)
              at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:521)
              at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:291)
              at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
              at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
              at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
              at com.sun.proxy.$Proxy228.isPDURequestSuccessful(Unknown Source)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
              at java.lang.reflect.Method.invoke(Method.java:498)
              at org.apache.camel.component.bean.MethodInfo.invoke(MethodInfo.java:407)
              at org.apache.camel.component.bean.MethodInfo$1.doProceed(MethodInfo.java:278)
              at org.apache.camel.component.bean.MethodInfo$1.proceed(MethodInfo.java:251)
              at org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:166)
              at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:72)
              at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:398)
              at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)
              at org.apache.camel.processor.Pipeline.process(Pipeline.java:118)
              at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)
              at org.apache.camel.processor.ChoiceProcessor.process(ChoiceProcessor.java:111)
              at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:72)
              at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:398)
              at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)
              at org.apache.camel.processor.Pipeline.process(Pipeline.java:118)
              at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)
              at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)
              at org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:51)
              at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:110)
              at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:72)
              at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:398)
              at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)
              at org.apache.camel.processor.ChoiceProcessor.process(ChoiceProcessor.java:111)
              at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:72)
              at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:398)
              at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)
              at org.apache.camel.processor.Pipeline.process(Pipeline.java:118)
              at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)
              at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)
              at org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:51)
              at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:110)
              at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:72)
              at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:398)
              at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)
              at org.apache.camel.processor.Pipeline.process(Pipeline.java:118)
              at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)
              at org.apache.camel.processor.ChoiceProcessor.process(ChoiceProcessor.java:111)
              at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:72)
              at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:398)
              at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)
              at org.apache.camel.processor.Pipeline.process(Pipeline.java:118)
              at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)
              at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)
              at org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:51)
              at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)
              at org.apache.camel.processor.UnitOfWorkProducer.process(UnitOfWorkProducer.java:73)
              at org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:378)
              at org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:346)
              at org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:242)
              at org.apache.camel.impl.ProducerCache.sendExchange(ProducerCache.java:346)
              at org.apache.camel.impl.ProducerCache.send(ProducerCache.java:184)
              at org.apache.camel.impl.DefaultProducerTemplate.send(DefaultProducerTemplate.java:124)
              at org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:137)
              at org.apache.camel.impl.DefaultProducerTemplate$14.call(DefaultProducerTemplate.java:621)
              at java.util.concurrent.FutureTask.run(FutureTask.java:266)
              at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
              at java.lang.Thread.run(Thread.java:745)

我可以通过增加Wildfly设置中的超时来实现它,但这是一个全局设置。无论如何我可以为特定路线设置相同的内容吗?

1 个答案:

答案 0 :(得分:1)

没有一种简单而干净的方式,至少不是我所知道的。您可以在the project's JIRA上要求改进,但在此之前,您可以尝试为路由定义自定义SpringTransactionPolicy,并使用设置了所需超时的自定义TransactionTemplate对其进行初始化。