在Apache Camel中汇总2个不同队列的消息时,获取AtomikosTransactionRequiredJMSException

时间:2018-10-08 07:37:58

标签: apache-camel aggregate spring-transactions spring-camel

我想将来自2个不同队列的两种不同类型的消息聚合到一条消息中。我在路由文件

中使用以下配置
from("activemq:queue1") //Receiving object of type A
.to ("direct:a");

from("activemq:queue2") //Receiving object of type B
.to ("direct:a");

from("direct:a") 
.aggregate().header("MCP_CORRELATION_ID")
.aggregationStrategy(new GroupedExchangeAggregationStrategy())
.completionPredicate(somePredicateCondition)
.completionTimeout(2000)
.to("direct:processAggregatedResult");

在Cucumber测试用例中,这绝对可以正常工作。但是,当我实际运行此代码时,则当我的消息到达聚合器路由时,它将引发以下异常:

CamelExceptionCaught=org.springframework.jms.UncategorizedJmsException: Uncategorized exception occurred during JMS processing; nested exception is com.atomikos.jms.AtomikosTransactionRequiredJMSException: The JMS session you are using requires a JTA transaction context for the calling thread and none was found.
Please correct your code to do one of the following: 
1. start a JTA transaction if you want your JMS operations to be subject to JTA commit/rollback, or
2. increase the maxPoolSize of the AtomikosConnectionFactoryBean to avoid transaction timeout while waiting for a connection, or
3. create a non-transacted session and do session acknowledgment yourself, or
4. set localTransactionMode to true so connection-level commit/rollback are enabled.,

0 个答案:

没有答案