基本上,没有现成的“Oracle”注释可用于使RAC故障转移拦截器工作。但是很容易添加新的自定义注释,这将为您完成工作。
如果sprig数据oracle在您的类路径上
maven pom.xml文件
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-oracle</artifactId>
<version>1.2.1.RELEASE</version>
</dependency>
只需创建一个要使用的标记注释。
package org.example;
public @interface OracleFailover {
// just a marker annotation, no body
}
为其配置顾问
<aop:config>
<aop:advisor
pointcut="@annotation(org.example.OracleFailover)"
advice-ref="racFailoverInterceptor" order="1"/>
</aop:config>
<orcl:rac-failover-interceptor id="racFailoverInterceptor"/>
然后把它用在你的商业方法上
package org.example;
@Service
public class SomeBusinessService {
@OracleFailover
void doSomethingWithOracle(){
// body goes here
}
}
记住,RAC故障转移拦截器应该先于您的跨国拦截器,也就是说,如果在事务已处于活动状态时完成故障转移拦截器,故障转移将无法按预期工作。