Java Spring集成—多个Jboss实例侦听同一邮件服务器是否会导致重复?

Java Spring集成—多个Jboss实例侦听同一邮件服务器是否会导致重复?,java,spring,spring-integration,Java,Spring,Spring Integration,我有以下spring集成邮件配置。我的版本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/int

我有以下spring集成邮件配置。我的版本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>

javax.net.ssl.SSLSocketFactory
假的
imaps
假的
问题


Jboss服务器的两个实例运行在不同的节点上,并且都指向同一个邮件服务器。我正在DefaultEmailReceiverUtilService类中插入一些DB。数据库中是否可能有一个邮件双重条目?换句话说,相同的邮件将由两个Jboss处理。如果是,那么如何避免这种行为?

是的,电子邮件不是事务性资源。一种技术是确保一次只运行一个适配器,根据需要使用JMX等启动/停止适配器-将auto startup设置为“false”,以防止它们在初始化期间启动,并使用管理软件控制它们。“监控”示例应用程序(在中间文件夹中)中显示了如何使用另一个Spring集成应用程序来管理另一个应用程序中的适配器的示例

如果需要多个实例来处理工作负载,那么可以使用AMQP、JMS等将工作分配给其他实例


如果第二个实例仅用于恢复,则您的管理应用程序可以监视这两个实例,如果其中一个实例出现故障,则启动另一个实例中的适配器。

这肯定是一个竞争条件。你必须考虑某种形式的电子邮件阅读/处理的交易。谢谢加里,我正在查看这些样本,我的SI版本是1.0.4(不可能升级)。我脑子里的一个快速的想法是:“这个工作是1.0.4吗?”从这个看来,1.0.4对于Spring集成JMX来说是不可用的。那么我还有其他选择吗?对不起-没有-利用所有优秀的工作并升级到当前版本会让您受益匪浅。