春のブート処理中のOracle DBのフェイルオーバー

Sunleo:

私は、プライマリDBは要求と二デシベルは、アプリケーションのサポートを提供するために開始します、サーバーに障害が発生している場所に現在のDBの詳細をログに記録します注釈ベースのインターセプターを作成したいと思います。

私は、上記のリンクからコードの下に見つかりましたが、私はこれを見つけるために、以下の、してください助けにAOPのための@Aspectのような注釈を使用する必要があり、特定のORCLアノテーションを見つけることができませんでした。

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xmlns:orcl="http://www.springframework.org/schema/data/orcl"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
       http://www.springframework.org/schema/aop
       http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
       http://www.springframework.org/schema/tx
       http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
       http://www.springframework.org/schema/data/orcl
       http://www.springframework.org/schema/data/orcl/spring-data-orcl-1.0.xsd">

    <aop:config>
        <aop:advisor pointcut="execution(* *..PetStoreFacade.insertOrder(..))" 1 
            advice-ref="racFailoverInterceptor" order="1"/>
        <aop:advisor pointcut="execution(* *..PetStoreFacade.*(..))" 2 
            advice-ref="txAdvice"/>
    </aop:config>

    <orcl:rac-failover-interceptor id="racFailoverInterceptor"/> 3

    <tx:advice id="txAdvice">
        <tx:attributes>
            <tx:method name="insert*"/>
            <tx:method name="update*"/>
            <tx:method name="*" read-only="true"/>
        </tx:attributes>
    </tx:advice>

</beans>

https://docs.spring.io/spring-data/jdbc/old-docs/2.0.0.BUILD-SNAPSHOT/reference/html/orcl.failover.html

BBL:

基本的には、RACのフェイルオーバーインターセプタの仕事を作るために使用することができるボックス「オラクル」注釈のないうちはありません。しかし、あなたのための作業を行います新しいカスタム注釈を追加するのは簡単です。

小枝データオラクルがクラスパスにあると仮定すると

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フェイルオーバインターセプタは、フェールオーバーが仕事のトランザクションがすでにアクティブである場合、フェールオーバー傍受が行われた場合に予想されるようにはありません、あなたの国境を越えたインターセプター、前に行く必要があることを覚えておいてください。

おすすめ

転載: http://43.154.161.224:23101/article/api/json?id=213966&siteId=1