我正在使用 Apache Camel 2.22.0 的最新版本。
目前不推荐使用跟踪器。但是,根据文档,我们可以使用它。
为了存储消息,我正在使用camel-jpa并面临以下异常。我已经将骆驼跟踪的上下文设置为true,但是没有用。
例外:
[DEBUG] 2018-09-06 10:29:00.093 [scheduler_Worker-1] TransactionTemplate - Initiating transaction rollback on application exception
javax.persistence.TransactionRequiredException: no transaction is in progress
at org.hibernate.internal.SessionImpl.checkTransactionNeeded(SessionImpl.java:3467) ~[hibernate-core-5.2.12.Final.jar:5.2.12.Final]
at org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1427) ~[hibernate-core-5.2.12.Final.jar:5.2.12.Final]
at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1423) ~[hibernate-core-5.2.12.Final.jar:5.2.12.Final]
at org.apache.camel.component.jpa.JpaProducer$2.doInTransaction(JpaProducer.java:246) ~[camel-jpa-2.22.0.jar:2.22.0]
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:140) [spring-tx-5.0.2.RELEASE.jar:5.0.2.RELEASE]
at org.apache.camel.component.jpa.JpaProducer.processEntity(JpaProducer.java:209) [camel-jpa-2.22.0.jar:2.22.0]
at org.apache.camel.component.jpa.JpaProducer.process(JpaProducer.java:161) [camel-jpa-2.22.0.jar:2.22.0]
at org.apache.camel.processor.interceptor.DefaultTraceEventHandler.traceExchange(DefaultTraceEventHandler.java:118) [camel-core-2.22.0.jar:2.22.0]
at org.apache.camel.processor.interceptor.TraceInterceptor.traceExchange(TraceInterceptor.java:309) [camel-core-2.22.0.jar:2.22.0]
at org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:167) [camel-core-2.22.0.jar:2.22.0]
at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:548) [camel-core-2.22.0.jar:2.22.0]
at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:406) [camel-core-2.22.0.jar:2.22.0]
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:176) [camel-core-2.22.0.jar:2.22.0]
at org.apache.camel.processor.Pipeline.process(Pipeline.java:138) [camel-core-2.22.0.jar:2.22.0]
at org.apache.camel.processor.Pipeline.process(Pipeline.java:101) [camel-core-2.22.0.jar:2.22.0]
at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:548) [camel-core-2.22.0.jar:2.22.0]
at org.apache.camel.spring.spi.TransactionErrorHandler.processByErrorHandler(TransactionErrorHandler.java:220) [camel-spring-2.22.0.jar:2.22.0]
at org.apache.camel.spring.spi.TransactionErrorHandler.process(TransactionErrorHandler.java:101) [camel-spring-2.22.0.jar:2.22.0]
at org.apache.camel.spring.spi.TransactionErrorHandler.process(TransactionErrorHandler.java:114) [camel-spring-2.22.0.jar:2.22.0]
at org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:181) [camel-core-2.22.0.jar:2.22.0]
at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:548) [camel-core-2.22.0.jar:2.22.0]
at org.apache.camel.spring.spi.TransactionErrorHandler.processByErrorHandler(TransactionErrorHandler.java:220) [camel-spring-2.22.0.jar:2.22.0]
at org.apache.camel.spring.spi.TransactionErrorHandler$1.doInTransactionWithoutResult(TransactionErrorHandler.java:183) [camel-spring-2.22.0.jar:2.22.0]
at org.springframework.transaction.support.TransactionCallbackWithoutResult.doInTransaction(TransactionCallbackWithoutResult.java:36) [spring-tx-5.0.2.RELEASE.jar:5.0.2.RELEASE]
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:140) [spring-tx-5.0.2.RELEASE.jar:5.0.2.RELEASE]
at org.apache.camel.spring.spi.TransactionErrorHandler.doInTransactionTemplate(TransactionErrorHandler.java:176) [camel-spring-2.22.0.jar:2.22.0]
at org.apache.camel.spring.spi.TransactionErrorHandler.processInTransaction(TransactionErrorHandler.java:136) [camel-spring-2.22.0.jar:2.22.0]
at org.apache.camel.spring.spi.TransactionErrorHandler.process(TransactionErrorHandler.java:105) [camel-spring-2.22.0.jar:2.22.0]
at org.apache.camel.spring.spi.TransactionErrorHandler.process(TransactionErrorHandler.java:114) [camel-spring-2.22.0.jar:2.22.0]
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201) [camel-core-2.22.0.jar:2.22.0]
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201) [camel-core-2.22.0.jar:2.22.0]
at org.apache.camel.processor.loadbalancer.QueueLoadBalancer.process(QueueLoadBalancer.java:44) [camel-core-2.22.0.jar:2.22.0]
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:109) [camel-core-2.22.0.jar:2.22.0]
at org.apache.camel.processor.loadbalancer.LoadBalancerSupport.process(LoadBalancerSupport.java:97) [camel-core-2.22.0.jar:2.22.0]
at org.apache.camel.component.quartz2.CamelJob.execute(CamelJob.java:58) [camel-quartz2-2.22.0.jar:2.22.0]
at org.quartz.core.JobRunShell.run(JobRunShell.java:202) [quartz-2.3.0.jar:?]
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573) [quartz-2.3.0.jar:?]<br/>
代码:
@Override
public void configure() {
camelContext.setTracing(true);
from(CamelComponent.QUARTZ2 + COLON + DOUBLE_SLASH + timerName + QUESTION_MARK + "cron=" + cronExpression)
.transacted()
.to(CamelComponent.SQL + COLON + sqlFile)
.bean(mapper, "map")
.bean(xStreamWriter, "toXml")
.to(buildFileUrl());
}<br/>
可能是什么原因?它不适用于事务。
提前谢谢,
最好的问候,
埃尔坎