我在骆驼routebuilder中有以下代码
public void method1(Exchange e){
//creates a new entity, say E1
//calls a service class with @Service and without @Transactional spring annotation
//(as guided in the Ref: below)
// to save the entity E1 using spring jpa repository
}
public void method2(Exchange e){
//..normal java statements ..//
}
from("file:/home/input")
.transacted("required") //Have a SpringTransactionPolicy in the registry
.process(this::method1)
.process(this::method2)
.to("file:/home/ouptut?fileName=demo.txt");
我发现即使处理了路由,在method1()完成后,E1仍在表中提交。我通过在method2()中启用调试指针来观察此行为。
Apache Camel版本:3.0.0
参考:Relation between Spring @Transactional and Camel Transacted
这是错误吗?
我对你的问题感到困惑。 transacted()
行的目的是创建JTA事务上下文。这使您可以将事务分组(同步)在一起。 file
端点未交易,并且似乎您的process
端点均未交易。没有要同步的内容。