我目前正在开展一个项目,该项目将轮询电子邮件收件箱以获取每日报告。
在访问托管在 Amazon Workmail 上的电子邮件用户时,我有一个使用带有 imapInboundAdapter 的 spring-integration-mail 的工作实现。
当收件箱中有一封未读且未标记的电子邮件时,它会接收该电子邮件并仅正确发出一封邮件。
但是,当我将电子邮件服务器更改为由 Outlook 托管的服务器时,我反而在同一次投票中收到了两次电子邮件。
据我所知,电子邮件的已看到/标志状态似乎在 Outlook 上的第二次轮询尝试之前没有更新,但在工作邮件的第一次尝试时更新。
Outlook 的第二次尝试检索应该已经处理的电子邮件。
IntegrationFlows
.from(
Mail.imapInboundAdapter(format("imaps://%s:%s/INBOX", source.getHost(), source.getPort()))
.javaMailAuthenticator(authenticator)
.maxFetchSize(10),
e -> e.poller(... maxMessagesPerPoll = -1, cronTrigger = "*/15 * * ? * *" ...)
).log(INFO, m -> "Received email: " + m)
这是点击工作邮件时发生的日志记录:
com.sun.mail.imap.connectionpool : getStoreProtocol() - connection available -- size: 1
com.sun.mail.imap.connectionpool : getStoreProtocol() -- storeConnectionInUse
com.sun.mail.imap : IMAPProtocol noop
com.sun.mail.imap.connectionpool : releaseStoreProtocol()
com.sun.mail.imap.connectionpool : getStoreProtocol() borrowing a connection
com.sun.mail.imap.connectionpool : getStoreProtocol() - connection available -- size: 1
com.sun.mail.imap.connectionpool : getStoreProtocol() -- storeConnectionInUse
com.sun.mail.imap.connectionpool : releaseFolderStoreProtocol()
o.s.integration.mail.ImapMailReceiver : opening folder [imaps://[SNIPPED]@imap.mail.us-west-2.awsapps.com:993/INBOX]
com.sun.mail.imap : connection available -- size: 1
com.sun.mail.imap.messagecache : create cache of size 8
o.s.integration.mail.ImapMailReceiver : attempting to receive mail from folder [INBOX]
o.s.integration.mail.ImapMailReceiver : This email server does not support RECENT or USER flags. System flag 'Flag.FLAGGED' will be used to prevent duplicates during email fetch.
com.sun.mail.imap.messagecache : create message number 8
o.s.integration.mail.ImapMailReceiver : found 1 new messages
o.s.integration.mail.ImapMailReceiver : Received 1 messages
o.s.integration.mail.ImapMailReceiver : USER flags are not supported by this mail server. Flagging message with system flag
com.sun.mail.imap.connectionpool : connection pool current size: 0 pool size: 1
com.sun.mail.imap.connectionpool : connection pool current size: 0 pool size: 1
com.sun.mail.imap : added an Authenticated connection -- size: 1
o.s.i.mail.MailReceivingMessageSource : received mail message [org.springframework.integration.mail.AbstractMailReceiver$IntegrationMimeMessage@a101a27]
o.s.integration.handler.LoggingHandler : Received email: GenericMessage [payload=org.springframework.integration.mail.AbstractMailReceiver$IntegrationMimeMessage@a101a27, headers={id=20fb1886-eeda-c1e2-7ce0-8a9aae4f7ebc, timestamp=1624590243455}]
com.sun.mail.imap.connectionpool : getStoreProtocol() - connection available -- size: 1
com.sun.mail.imap.connectionpool : getStoreProtocol() -- storeConnectionInUse
com.sun.mail.imap : IMAPProtocol noop
com.sun.mail.imap.connectionpool : releaseStoreProtocol()
com.sun.mail.imap.connectionpool : getStoreProtocol() borrowing a connection
com.sun.mail.imap.connectionpool : getStoreProtocol() - connection available -- size: 1
com.sun.mail.imap.connectionpool : getStoreProtocol() -- storeConnectionInUse
com.sun.mail.imap.connectionpool : releaseFolderStoreProtocol()
o.s.integration.mail.ImapMailReceiver : opening folder [imaps://[SNIPPED]@imap.mail.us-west-2.awsapps.com:993/INBOX]
com.sun.mail.imap : connection available -- size: 1
com.sun.mail.imap.messagecache : create cache of size 8
o.s.integration.mail.ImapMailReceiver : attempting to receive mail from folder [INBOX]
o.s.integration.mail.ImapMailReceiver : This email server does not support RECENT or USER flags. System flag 'Flag.FLAGGED' will be used to prevent duplicates during email fetch.
o.s.integration.mail.ImapMailReceiver : found 0 new messages
o.s.integration.mail.ImapMailReceiver : Received 0 messages
com.sun.mail.imap.connectionpool : connection pool current size: 0 pool size: 1
com.sun.mail.imap.connectionpool : connection pool current size: 0 pool size: 1
com.sun.mail.imap : added an Authenticated connection -- size: 1
这是点击 Outlook 时发生的日志记录:
com.sun.mail.imap.connectionpool : getStoreProtocol() - connection available -- size: 1
com.sun.mail.imap.connectionpool : getStoreProtocol() -- storeConnectionInUse
com.sun.mail.imap : IMAPProtocol noop
com.sun.mail.imap.connectionpool : releaseStoreProtocol()
com.sun.mail.imap.connectionpool : getStoreProtocol() borrowing a connection
com.sun.mail.imap.connectionpool : getStoreProtocol() - connection available -- size: 1
com.sun.mail.imap.connectionpool : getStoreProtocol() -- storeConnectionInUse
com.sun.mail.imap.connectionpool : releaseFolderStoreProtocol()
o.s.integration.mail.ImapMailReceiver : opening folder [imaps://[SNIPPED]@outlook.office365.com:993/INBOX]
com.sun.mail.imap : connection available -- size: 1
com.sun.mail.imap.messagecache : create cache of size 2
o.s.integration.mail.ImapMailReceiver : attempting to receive mail from folder [INBOX]
o.s.integration.mail.ImapMailReceiver : This email server does not support RECENT or USER flags. System flag 'Flag.FLAGGED' will be used to prevent duplicates during email fetch.
com.sun.mail.imap.messagecache : create message number 2
o.s.integration.mail.ImapMailReceiver : found 1 new messages
o.s.integration.mail.ImapMailReceiver : Received 1 messages
o.s.integration.mail.ImapMailReceiver : USER flags are not supported by this mail server. Flagging message with system flag
com.sun.mail.imap.connectionpool : connection pool current size: 0 pool size: 1
com.sun.mail.imap.connectionpool : connection pool current size: 0 pool size: 1
com.sun.mail.imap : added an Authenticated connection -- size: 1
o.s.i.mail.MailReceivingMessageSource : received mail message [org.springframework.integration.mail.AbstractMailReceiver$IntegrationMimeMessage@5dffc30b]
o.s.integration.handler.LoggingHandler : Received email: GenericMessage [payload=org.springframework.integration.mail.AbstractMailReceiver$IntegrationMimeMessage@5dffc30b, headers={id=9d158e52-d46e-fd82-38b7-b438a4899a1e, timestamp=1624589763164}]
com.sun.mail.imap.connectionpool : getStoreProtocol() - connection available -- size: 1
com.sun.mail.imap.connectionpool : getStoreProtocol() -- storeConnectionInUse
com.sun.mail.imap : IMAPProtocol noop
com.sun.mail.imap.connectionpool : releaseStoreProtocol()
com.sun.mail.imap.connectionpool : getStoreProtocol() borrowing a connection
com.sun.mail.imap.connectionpool : getStoreProtocol() - connection available -- size: 1
com.sun.mail.imap.connectionpool : getStoreProtocol() -- storeConnectionInUse
com.sun.mail.imap.connectionpool : releaseFolderStoreProtocol()
o.s.integration.mail.ImapMailReceiver : opening folder [imaps://[SNIPPED]@outlook.office365.com:993/INBOX]
com.sun.mail.imap : connection available -- size: 1
com.sun.mail.imap.messagecache : create cache of size 2
o.s.integration.mail.ImapMailReceiver : attempting to receive mail from folder [INBOX]
o.s.integration.mail.ImapMailReceiver : This email server does not support RECENT or USER flags. System flag 'Flag.FLAGGED' will be used to prevent duplicates during email fetch.
com.sun.mail.imap.messagecache : create message number 2
o.s.integration.mail.ImapMailReceiver : found 1 new messages
o.s.integration.mail.ImapMailReceiver : Received 1 messages
o.s.integration.mail.ImapMailReceiver : USER flags are not supported by this mail server. Flagging message with system flag
com.sun.mail.imap.connectionpool : connection pool current size: 0 pool size: 1
com.sun.mail.imap.connectionpool : connection pool current size: 0 pool size: 1
com.sun.mail.imap : added an Authenticated connection -- size: 1
o.s.i.mail.MailReceivingMessageSource : received mail message [org.springframework.integration.mail.AbstractMailReceiver$IntegrationMimeMessage@59c04c6c]
o.s.integration.handler.LoggingHandler : Received email: GenericMessage [payload=org.springframework.integration.mail.AbstractMailReceiver$IntegrationMimeMessage@59c04c6c, headers={id=002e6b83-caf5-86cd-b090-44aa346df119, timestamp=1624589766210}]
com.sun.mail.imap.connectionpool : getStoreProtocol() - connection available -- size: 1
com.sun.mail.imap.connectionpool : getStoreProtocol() -- storeConnectionInUse
com.sun.mail.imap : IMAPProtocol noop
com.sun.mail.imap.connectionpool : releaseStoreProtocol()
com.sun.mail.imap.connectionpool : getStoreProtocol() borrowing a connection
com.sun.mail.imap.connectionpool : getStoreProtocol() - connection available -- size: 1
com.sun.mail.imap.connectionpool : getStoreProtocol() -- storeConnectionInUse
com.sun.mail.imap.connectionpool : releaseFolderStoreProtocol()
o.s.integration.mail.ImapMailReceiver : opening folder [imaps://[SNIPPED]@outlook.office365.com:993/INBOX]
com.sun.mail.imap : connection available -- size: 1
com.sun.mail.imap.messagecache : create cache of size 2
o.s.integration.mail.ImapMailReceiver : attempting to receive mail from folder [INBOX]
o.s.integration.mail.ImapMailReceiver : This email server does not support RECENT or USER flags. System flag 'Flag.FLAGGED' will be used to prevent duplicates during email fetch.
o.s.integration.mail.ImapMailReceiver : found 0 new messages
o.s.integration.mail.ImapMailReceiver : Received 0 messages
com.sun.mail.imap.connectionpool : connection pool current size: 0 pool size: 1
com.sun.mail.imap.connectionpool : connection pool current size: 0 pool size: 1
com.sun.mail.imap : added an Authenticated connection -- size: 1