ImapIdleChannelAdapter:空闲任务中发生错误

时间:2017-08-22 12:52:09

标签: spring-boot spring-integration imap

我在基于Spring Boot 1.4.3的应用程序中遇到以下异常。它使用Spring Integration 4.3.6。

imap-server是MS-Exchange。

有什么想法来自哪里?

Aug 22 14:46:42 2017-08-22 14:46:42.631  WARN 537 --- [ask-scheduler-1] o.s.i.mail.ImapIdleChannelAdapter        : error occurred in idle task
Aug 22 14:46:42 javax.mail.FolderClosedException: * BYE JavaMail Exception: java.io.IOException: Connection dropped by server?
Aug 22 14:46:42 at com.sun.mail.imap.IMAPFolder.handleIdle(IMAPFolder.java:3199)
Aug 22 14:46:42 at com.sun.mail.imap.IMAPFolder.idle(IMAPFolder.java:3043)
Aug 22 14:46:42 at com.sun.mail.imap.IMAPFolder.idle(IMAPFolder.java:2995)
Aug 22 14:46:42 at org.springframework.integration.mail.ImapMailReceiver.waitForNewMessages(ImapMailReceiver.java:175)
Aug 22 14:46:42 at org.springframework.integration.mail.ImapIdleChannelAdapter$IdleTask.run(ImapIdleChannelAdapter.java:271)
Aug 22 14:46:42 at org.springframework.integration.mail.ImapIdleChannelAdapter$ReceivingTask.run(ImapIdleChannelAdapter.java:241)
Aug 22 14:46:42 at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
Aug 22 14:46:42 at org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:81)
Aug 22 14:46:42 at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
Aug 22 14:46:42 at java.util.concurrent.FutureTask.run(FutureTask.java:266)
Aug 22 14:46:42 at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
Aug 22 14:46:42 at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
Aug 22 14:46:42 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
Aug 22 14:46:42 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
Aug 22 14:46:42 at java.lang.Thread.run(Thread.java:745)

Aug 22 14:46:42 2017-08-22 14:46:42.632  WARN 537 --- [ask-scheduler-1] o.s.i.mail.ImapIdleChannelAdapter        : Failed to execute IDLE task. Will attempt to resubmit in 10000 milliseconds.
Aug 22 14:46:42 java.lang.IllegalStateException: Failure in 'idle' task. Will resubmit.
Aug 22 14:46:42 at org.springframework.integration.mail.ImapIdleChannelAdapter$IdleTask.run(ImapIdleChannelAdapter.java:290)
Aug 22 14:46:42 at org.springframework.integration.mail.ImapIdleChannelAdapter$ReceivingTask.run(ImapIdleChannelAdapter.java:241)
Aug 22 14:46:42 at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
Aug 22 14:46:42 at org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:81)
Aug 22 14:46:42 at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
Aug 22 14:46:42 at java.util.concurrent.FutureTask.run(FutureTask.java:266)
Aug 22 14:46:42 at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
Aug 22 14:46:42 at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
Aug 22 14:46:42 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
Aug 22 14:46:42 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
Aug 22 14:46:42 at java.lang.Thread.run(Thread.java:745)
Aug 22 14:46:42 Caused by: javax.mail.FolderClosedException: * BYE JavaMail Exception: java.io.IOException: Connection dropped by server?
Aug 22 14:46:42 at com.sun.mail.imap.IMAPFolder.handleIdle(IMAPFolder.java:3199)
Aug 22 14:46:42 at com.sun.mail.imap.IMAPFolder.idle(IMAPFolder.java:3043)
Aug 22 14:46:42 at com.sun.mail.imap.IMAPFolder.idle(IMAPFolder.java:2995)
Aug 22 14:46:42 at org.springframework.integration.mail.ImapMailReceiver.waitForNewMessages(ImapMailReceiver.java:175)
Aug 22 14:46:42 at org.springframework.integration.mail.ImapIdleChannelAdapter$IdleTask.run(ImapIdleChannelAdapter.java:271)
Aug 22 14:46:42 ... 10 common frames omitted

Spring Integration的配置如下:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
        http://www.springframework.org/schema/integration/mail http://www.springframework.org/schema/integration/mail/spring-integration-mail.xsd
        http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd"
    xmlns:int="http://www.springframework.org/schema/integration"
    xmlns:int-mail="http://www.springframework.org/schema/integration/mail"
    xmlns:util="http://www.springframework.org/schema/util">

    <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>

    <int:channel id="receiveChannel" datatype="javax.mail.Message" />

    <int-mail:imap-idle-channel-adapter
        id="customAdapter"
        store-uri="imaps://user:password@exchangehost/INBOX"
        channel="receiveChannel"
        auto-startup="true"
        should-delete-messages="true"
        should-mark-messages-as-read="true"
        java-mail-properties="javaMailProperties" />

</beans>

1 个答案:

答案 0 :(得分:2)

<prop key="mail.debug">true</prop>

这很像在客户端与服务器通信时出现问题,启用邮件调试日志可以帮助您检查根本原因。我有类似的情况,我的情况是服务器无法识别来自客户端的命令

IMAP email channel adapter throw exception "A5 BAD invalid command or parameters;"