【问题标题】:imap-idle-channel-adapter in a cluster environment集群环境中的 imap-idle-channel-adapter
【发布时间】:2021-10-03 16:05:09
【问题描述】:

一个使用 Spring Integration (imap-idle-channel-adapter) 和 Spring Boot 的应用程序部署在 Weblogic Cluster 环境(4 个服务器)中。 如果将 SI 适配器 imap-idle-channel-adapter 部署在一台服务器中,则它可以很好地从 Exchange Server 中提取电子邮件。 但是,如果它部署在集群中(4 个服务器),则电子邮件会被处理 4 次(每台服务器一个)。

问题:在集群环境中部署此类应用程序是否有任何配置或良好做法?

使用:

  • Spring Boot 2.5.1
  • Spring 集成邮件 5.5.0
  • Weblogic 12c

在此博客之后创建了一个战争文件。

https://o7planning.org/11901/deploy-spring-boot-application-on-oracle-weblogic-server

imap-idle-channel-adapter和mail属性的配置是这样的。

  <int-mail:imap-idle-channel-adapter id="customAdapter"
     store-uri="imaps://[username]:[password]@imap.gmail.com/INBOX"
     channel="receiveChannel"
     auto-startup="true"
     should-delete-messages="false"
     auto-close-folder="false"
     simple-content="true"
     java-mail-properties="javaMailProperties"/>
  
  <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>

【问题讨论】:

  • 我不这么认为;您可以在不同的主机上使用不同的帐户,但协调对单个帐户的“首次访问”并不是 IMAP 真正支持的。
  • 在这里提出了类似的问题:stackoverflow.com/questions/68333194/…

标签: spring-boot spring-integration imap weblogic12c


【解决方案1】:

嗯,从技术上讲,它必须是这样的,因为默认的SearchTerm 是不拉取DELETED 或SEEN 的消息。如果您的邮件服务器不支持这些标志,则使用USER。而且由于您没有指定一些自定义,因此在您的所有实例上总是相同的 - spring-integration-mail-adapter。

但是感觉 Exchange Server 以异步方式设置这些标志,因为您声称所有实例都收到相同的消息。

因此,另一种方法是通过共享元数据存储和幂等接收器在您的应用程序中使用人造的东西:https://docs.spring.io/spring-integration/docs/current/reference/html/messaging-endpoints.html#idempotent-receiver。

您也可以自定义SearchTermStrategy,以其他方式过滤来自邮箱的消息,而不是我们尝试在默认的SEEN 和USER 中执行的操作:https://docs.spring.io/spring-integration/docs/current/reference/html/mail.html#imap-seen

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-01-21
  • 2010-11-14
  • 1970-01-01
相关资源
最近更新 更多