在我的项目中,我正在使用具有以下配置的imap空闲通道适配器:
@Bean
public IntegrationFlow imapAdapter(MailNotifierProperties properties, SubscribableChannel errorChannel,
SubscribableChannel incomingMailChannel) {
return from(Mail.imapIdleAdapter(properties.getImapUrl())
.javaMailProperties(p -> p
.put("mail.imap.starttls.enable", "true")
.put("mail.imap.ssl.trust", "*"))
.errorChannel(errorChannel)
.shouldDeleteMessages(properties.getDeleteMessages()))
.channel(incomingMailChannel)
.get();
}
大多数情况下,配置工作正常。但是我每天一两次遇到以下异常,并且该应用程序无法处理大约30分钟的邮件:
2018-11-18 07:05:45.342 WARN 19778 --- [TaskScheduler19] o.s.i.mail.ImapIdleChannelAdapter : error occurred in idle task
javax.mail.MessagingException: * NO Mailbox is locked, will abort in 268 seconds
at com.sun.mail.imap.IMAPFolder.handleIdle(IMAPFolder.java:3201) ~[javax.mail-1.5.5.jar!/:1.5.5]
at com.sun.mail.imap.IMAPFolder.idle(IMAPFolder.java:3043) ~[javax.mail-1.5.5.jar!/:1.5.5]
at com.sun.mail.imap.IMAPFolder.idle(IMAPFolder.java:2995) ~[javax.mail-1.5.5.jar!/:1.5.5]
at org.springframework.integration.mail.ImapMailReceiver.waitForNewMessages(ImapMailReceiver.java:175) ~[spring-integration-mail-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
at org.springframework.integration.mail.ImapIdleChannelAdapter$IdleTask.run(ImapIdleChannelAdapter.java:271) ~[spring-integration-mail-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
at org.springframework.integration.mail.ImapIdleChannelAdapter$ReceivingTask.run(ImapIdleChannelAdapter.java:241) [spring-integration-mail-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54) [spring-context-4.3.3.RELEASE.jar!/:4.3.3.RELEASE]
at org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:81) [spring-context-4.3.3.RELEASE.jar!/:4.3.3.RELEASE]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_121]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_121]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) [na:1.8.0_121]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [na:1.8.0_121]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_121]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_121]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_121]
Caused by: com.sun.mail.iap.CommandFailedException: * NO Mailbox is locked, will abort in 268 seconds
at com.sun.mail.iap.Protocol.handleResult(Protocol.java:396) ~[javax.mail-1.5.5.jar!/:1.5.5]
at com.sun.mail.imap.protocol.IMAPProtocol.processIdleResponse(IMAPProtocol.java:3225) ~[javax.mail-1.5.5.jar!/:1.5.5]
at com.sun.mail.imap.IMAPFolder.handleIdle(IMAPFolder.java:3173) ~[javax.mail-1.5.5.jar!/:1.5.5]
... 14 common frames omitted
2018-11-18 07:05:45.343 WARN 19778 --- [TaskScheduler19] o.s.i.mail.ImapIdleChannelAdapter : Failed to execute IDLE task. Will attempt to resubmit in 10000 milliseconds.
java.lang.IllegalStateException: Failure in 'idle' task. Will resubmit.
at org.springframework.integration.mail.ImapIdleChannelAdapter$IdleTask.run(ImapIdleChannelAdapter.java:290) ~[spring-integration-mail-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
at org.springframework.integration.mail.ImapIdleChannelAdapter$ReceivingTask.run(ImapIdleChannelAdapter.java:241) ~[spring-integration-mail-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54) [spring-context-4.3.3.RELEASE.jar!/:4.3.3.RELEASE]
at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54) [spring-context-4.3.3.RELEASE.jar!/:4.3.3.RELEASE]
at org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:81) [spring-context-4.3.3.RELEASE.jar!/:4.3.3.RELEASE]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_121]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_121]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) [na:1.8.0_121]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [na:1.8.0_121]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_121]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_121]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_121]
Caused by: javax.mail.MessagingException: * NO Mailbox is locked, will abort in 268 seconds
at com.sun.mail.imap.IMAPFolder.handleIdle(IMAPFolder.java:3201) ~[javax.mail-1.5.5.jar!/:1.5.5]
at com.sun.mail.imap.IMAPFolder.idle(IMAPFolder.java:3043) ~[javax.mail-1.5.5.jar!/:1.5.5]
at com.sun.mail.imap.IMAPFolder.idle(IMAPFolder.java:2995) ~[javax.mail-1.5.5.jar!/:1.5.5]
at org.springframework.integration.mail.ImapMailReceiver.waitForNewMessages(ImapMailReceiver.java:175) ~[spring-integration-mail-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
at org.springframework.integration.mail.ImapIdleChannelAdapter$IdleTask.run(ImapIdleChannelAdapter.java:271) ~[spring-integration-mail-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
... 10 common frames omitted
Caused by: com.sun.mail.iap.CommandFailedException: * NO Mailbox is locked, will abort in 268 seconds
at com.sun.mail.iap.Protocol.handleResult(Protocol.java:396) ~[javax.mail-1.5.5.jar!/:1.5.5]
at com.sun.mail.imap.protocol.IMAPProtocol.processIdleResponse(IMAPProtocol.java:3225) ~[javax.mail-1.5.5.jar!/:1.5.5]
at com.sun.mail.imap.IMAPFolder.handleIdle(IMAPFolder.java:3173) ~[javax.mail-1.5.5.jar!/:1.5.5]
... 14 common frames omitted
2018-11-18 07:36:51.824 WARN 19778 --- [TaskScheduler19] o.s.i.mail.ImapIdleChannelAdapter : error occurred in idle task
javax.mail.FolderClosedException: * BYE Disconnected for inactivity.
at com.sun.mail.imap.IMAPFolder.throwClosedException(IMAPFolder.java:3601) ~[javax.mail-1.5.5.jar!/:1.5.5]
at com.sun.mail.imap.IMAPFolder.doCommand(IMAPFolder.java:3737) ~[javax.mail-1.5.5.jar!/:1.5.5]
at com.sun.mail.imap.IMAPFolder.exists(IMAPFolder.java:583) ~[javax.mail-1.5.5.jar!/:1.5.5]
at org.springframework.integration.mail.AbstractMailReceiver.openFolder(AbstractMailReceiver.java:299) ~[spring-integration-mail-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
at org.springframework.integration.mail.ImapMailReceiver.waitForNewMessages(ImapMailReceiver.java:158) ~[spring-integration-mail-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
at org.springframework.integration.mail.ImapIdleChannelAdapter$IdleTask.run(ImapIdleChannelAdapter.java:271) ~[spring-integration-mail-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
at org.springframework.integration.mail.ImapIdleChannelAdapter$ReceivingTask.run(ImapIdleChannelAdapter.java:241) [spring-integration-mail-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54) [spring-context-4.3.3.RELEASE.jar!/:4.3.3.RELEASE]
at org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:81) [spring-context-4.3.3.RELEASE.jar!/:4.3.3.RELEASE]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_121]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_121]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) [na:1.8.0_121]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [na:1.8.0_121]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_121]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_121]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_121]
2018-11-18 07:36:51.824 WARN 19778 --- [TaskScheduler19] o.s.i.mail.ImapIdleChannelAdapter : Failed to execute IDLE task. Will attempt to resubmit in 10000 milliseconds.
java.lang.IllegalStateException: Failure in 'idle' task. Will resubmit.
at org.springframework.integration.mail.ImapIdleChannelAdapter$IdleTask.run(ImapIdleChannelAdapter.java:290) ~[spring-integration-mail-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
at org.springframework.integration.mail.ImapIdleChannelAdapter$ReceivingTask.run(ImapIdleChannelAdapter.java:241) ~[spring-integration-mail-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54) [spring-context-4.3.3.RELEASE.jar!/:4.3.3.RELEASE]
at org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:81) [spring-context-4.3.3.RELEASE.jar!/:4.3.3.RELEASE]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_121]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_121]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) [na:1.8.0_121]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [na:1.8.0_121]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_121]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_121]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_121]
Caused by: javax.mail.FolderClosedException: * BYE Disconnected for inactivity.
at com.sun.mail.imap.IMAPFolder.throwClosedException(IMAPFolder.java:3601) ~[javax.mail-1.5.5.jar!/:1.5.5]
at com.sun.mail.imap.IMAPFolder.doCommand(IMAPFolder.java:3737) ~[javax.mail-1.5.5.jar!/:1.5.5]
at com.sun.mail.imap.IMAPFolder.exists(IMAPFolder.java:583) ~[javax.mail-1.5.5.jar!/:1.5.5]
at org.springframework.integration.mail.AbstractMailReceiver.openFolder(AbstractMailReceiver.java:299) ~[spring-integration-mail-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
at org.springframework.integration.mail.ImapMailReceiver.waitForNewMessages(ImapMailReceiver.java:158) ~[spring-integration-mail-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
at org.springframework.integration.mail.ImapIdleChannelAdapter$IdleTask.run(ImapIdleChannelAdapter.java:271) ~[spring-integration-mail-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
... 10 common frames omitted
2018-11-18 07:37:01.872 INFO 19778 --- [TaskScheduler19] o.s.integration.mail.ImapMailReceiver : attempting to receive mail from folder [INBOX]
现在我没有下列问题的答案 1)是什么导致错误消息:“ *没有邮箱已锁定,将在268秒后中止”? 2)为什么在接下来的30分钟之内没有邮件处理?
更新: 我已经检查了服务器上的日志文件,并且可以找到同时发生的以下消息:
Nov 18 07:05:33 MailServer postfix/local[19960]: 5D5AAC20FA: to=<sender@domain.com>, orig_to=<recipient@domain.com>, relay=local, delay=19, delays=0.01/0/0/19, dsn=4.2.0, status=deferred (cannot update mailbox /var/mail/mailUser for user mailUser. unable to lock for exclusive access: Resource temporarily unavailable)
但是,锁定邮箱的文件将在30秒后删除。
是否可以将imap通道适配器配置为在较短的时间内重新连接。我仍然有问题,该应用程序要等待30分钟才能重新连接到邮箱。
答案 0 :(得分:0)
该邮件来自您的邮件服务器,因此您需要询问邮件服务器的所有者,或者如果它是您自己的邮件服务器,则需要查看日志文件,以查看其为何抱怨邮箱被锁定。也许有两个应用程序正在尝试访问同一邮箱,而邮件服务器一次不能处理一个以上的应用程序访问邮箱?