2

次の春統合メール構成があります。私のバージョン1.0.4

<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:mail="http://www.springframework.org/schema/integration/mail"
xmlns:int="http://www.springframework.org/schema/integration"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="
    http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
    http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
    http://www.springframework.org/schema/integration/mail
    http://www.springframework.org/schema/integration/mail/spring-integration-mail-2.1.xsd 
    http://www.springframework.org/schema/util 
    http://www.springframework.org/schema/util/spring-util-2.0.xsd">


    <util:properties id="javaMailProperties">
    <prop key="mail.imap.socketFactory.class">javax.net.ssl.SSLSocketFactory</prop>
    <prop key="mail.imap.socketFactory.fallback">false</prop>
    <prop key="mail.store.protocol">imaps</prop>
    <prop key="mail.debug">false</prop>
</util:properties>

 <mail:inbound-channel-adapter id="imapAdapter"
                                  store-uri="imaps://user:pass@domain:993/inbox"                                    
                                  channel="recieveEmailChannel"
                                  auto-startup="true"                                      
                                  java-mail-properties="javaMailProperties">
    <int:poller> 
    <int:interval-trigger initial-delay="1000" interval="2000"
    fixed-rate="true"/>
    </int:poller>
</mail:inbound-channel-adapter>

<int:channel id="recieveEmailChannel">        
    <int:interceptors>
        <int:wire-tap channel="logger"/>
    </int:interceptors>
</int:channel>

<int:logging-channel-adapter id="logger" level="DEBUG"/>

<int:service-activator input-channel="recieveEmailChannel" ref="emailReceiverService" method="receive"/>

<bean id="emailReceiverService" class="com.mycompany.DefaultEmailReceiverUtilService">
</bean>

質問

Jboss サーバーの 2 つのインスタンスが異なるノードで実行されており、両方が同じメール サーバーを指しています。DefaultEmailReceiverUtilService クラスで DB 挿入を行っています。データベース内の 1 つのメール デュアル エントリは可能ですか? つまり、同じメールが両方の Jboss によって処理されます。はいの場合、この動作を回避する方法は?

4

1 に答える 1

2

はい、電子メールはトランザクション リソースではありません。1 つの手法は、一度に 1 つのアダプターのみが実行されるようにすることです。JMX などを使用して、必要に応じてアダプターを開始/停止します。自動開始を「false」に設定して、初期化中にアダプターが開始されないようにし、管理ソフトウェアを使用してそれらを制御します。 . 別の Spring Integration アプリケーションを使用して別のアダプターを管理する方法の例は、「監視」サンプルアプリ (中間フォルダー内) に示されています...

https://github.com/SpringSource/spring-integration-samples

ワークロードを処理するために複数のインスタンスが必要な場合は、AMQP、JMS などを使用して他のインスタンスに作業を分散できます。

2 番目のインスタンスが単に回復力のためである場合、管理アプリは 2 つのインスタンスを監視し、一方がダウンした場合は他方でアダプターを起動できます。

于 2013-01-10T13:32:20.637 に答える