Spring boot Apache Camel 3.7.3和transaced()隔离
假设我有一条路线Spring boot Apache Camel 3.7.3和transaced()隔离,spring-boot,apache-camel,Spring Boot,Apache Camel,假设我有一条路线 import org.apache.camel.builder.RouteBuilder; class MyRouteBuilder extends RouteBuilder { public void configure() { from("file:src/data?noop=true") .transacted() .bean("accountServi
import org.apache.camel.builder.RouteBuilder;
class MyRouteBuilder extends RouteBuilder {
public void configure() {
from("file:src/data?noop=true")
.transacted()
.bean("accountService","credit")
.bean("accountService","debit");
}
}
如您所见,我正在使用Transact(),我知道如何选择事务传播策略,即
必需的\u新的
,传播\u必需的
,等等
但是,我不知道如何更改Transact()隔离级别,即如何设置它
到隔离级别可序列化
注:
我正在使用
JAVA 11
SpringBoot 2.4.5
Apache Camel 3.7.3
事务处理方法可能引用持有所需事务策略的特定bean:
.transacted("PROPAGATION_REQUIRED")
或者,对于SpringRouteBuilder
,您可以使用Policy
对象:
public void configure() {
Policy myPolicy = bean(SpringTransactionPolicy.class, "PROPAGATION_REQUIRES_NEW"));
...
from("...")
.policy(myPolicy)
如果您想使用自定义隔离级别,我认为您必须创建一个
SpringTransactionPolicy
,并提供一个TransactionTemplate
实例:请参阅
这样,您将能够达到所需的隔离级别:
TransactionTemplate transactionTemplate = new TransactionTemplate(transactionManager);
transactionTemplate.setIsolationLevel(TransactionDefinition.ISOLATION_REPEATABLE_READ);
transactionTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
SpringTransactionPolicy customPolicy = new SpringTransactionPolicy(transactionTemplate);
from("...")
.policy(customPolicy)
感谢您的回复,我不是在看如何设置事务传播,而是在看如何添加事务隔离,即默认、读提交、读未提交、可重复读、可序列化,但我能找到的只是如何设置传播级别,即传播需要、传播需要新