0
votes

An application that uses Spring Integration (imap-idle-channel-adapter) and Spring Boot was deployed in a Weblogic Cluster environment (4 servers). The SI adapter imap-idle-channel-adapter pulls emails from Exchange Server fine if it is deployed in one server. However, if it is deployed in cluster (4 servers), the email is processed 4 times (one per each server).

Question: Is there any configuration or good practice for deploying this type of application in a cluster environment?

Using:

  • Spring Boot 2.5.1
  • Spring Integration Mail 5.5.0
  • Weblogic 12c

A war file was created following this blog.

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

The configuration of the imap-idle-channel-adapter and mail properties are like this.

  <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>
1
I don’t think so; you could use different accounts on different hosts, but coordinating “first access” to a single account is not really something IMAP supports.Max
Similar question was asked here: stackoverflow.com/questions/68333194/…Artem Bilan

1 Answers

1
votes

Well, technically it must be like that because a default SearchTerm is to not pull messages which are DELETED or SEEN. If those flags are not supported by your mail server, then USER is used. And since you don't specify some custom, it is always the same on all your instances - spring-integration-mail-adapter.

However it feels like that Exchange Server sets those flags in async manner, since you claim that all your instances get the same message.

So, another way is to use something artificial in your application via shared metadata store and Idempotent Receiver: https://docs.spring.io/spring-integration/docs/current/reference/html/messaging-endpoints.html#idempotent-receiver.

You may also make your own custom SearchTermStrategy to filter out messages from the mail box some other way, than what we try to do with those SEEN and USER in a default one: https://docs.spring.io/spring-integration/docs/current/reference/html/mail.html#imap-seen