我正在尝试使用Spring-Integration-Mail从电子邮件服务器获取电子邮件,下面是我得到的那种跟踪。
从程序的行为角度来看,我注意到只有在程序的初始运行时才能成功检索消息,之后看起来它没有收到任何新的电子邮件,可能是因为IDLE任务失败了?
无论如何,ArrayIndexOutOfBoundsException
对我来说似乎很奇怪。我只能告诉INBOX在此脚本运行时包含6条消息,但是其他文件夹中包含消息。
有什么想法吗?
2016-09-22 08:29:01,792 [task-scheduler-1] DEBUG o.s.i.m.ImapIdleChannelAdapter - waiting for mail
2016-09-22 08:29:02,138 [task-scheduler-1] DEBUG o.s.i.m.ImapMailReceiver - This email server does not support RECENT or USER flags. System flag 'Flag.FLAGGED' will be used to prevent duplicates during email fetch.
2016-09-22 08:29:02,375 [task-scheduler-1] WARN o.s.i.m.ImapIdleChannelAdapter - Failed to execute IDLE task. Will attempt to resubmit in 10000 milliseconds.
java.lang.ArrayIndexOutOfBoundsException: message number (7) out of bounds (6)
at com.sun.mail.imap.MessageCache.getMessage(MessageCache.java:135)
at com.sun.mail.imap.MessageCache.getMessageBySeqnum(MessageCache.java:164)
at com.sun.mail.imap.IMAPFolder.getMessageBySeqNumber(IMAPFolder.java:3005)
at com.sun.mail.imap.IMAPFolder.search(IMAPFolder.java:1863)
at org.springframework.integration.mail.ImapMailReceiver.searchForNewMessages(ImapMailReceiver.java:202)
at org.springframework.integration.mail.ImapMailReceiver.waitForNewMessages(ImapMailReceiver.java:167)
at org.springframework.integration.mail.ImapIdleChannelAdapter$IdleTask.run(ImapIdleChannelAdapter.java:220)
at org.springframework.integration.mail.ImapIdleChannelAdapter$ReceivingTask.run(ImapIdleChannelAdapter.java:190)
at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
at org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:81)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
2016-09-22 08:29:12,376 [task-scheduler-1] DEBUG o.s.i.m.ImapIdleChannelAdapter - waiting for mail
2016-09-22 08:29:12,739 [task-scheduler-1] DEBUG o.s.i.m.ImapMailReceiver - This email server does not support RECENT or USER flags. System flag 'Flag.FLAGGED' will be used to prevent duplicates during email fetch.
2016-09-22 08:29:12,970 [task-scheduler-1] WARN o.s.i.m.ImapIdleChannelAdapter - Failed to execute IDLE task. Will attempt to resubmit in 10000 milliseconds.
java.lang.ArrayIndexOutOfBoundsException: message number (7) out of bounds (6)
at com.sun.mail.imap.MessageCache.getMessage(MessageCache.java:135)
at com.sun.mail.imap.MessageCache.getMessageBySeqnum(MessageCache.java:164)
at com.sun.mail.imap.IMAPFolder.getMessageBySeqNumber(IMAPFolder.java:3005)
at com.sun.mail.imap.IMAPFolder.search(IMAPFolder.java:1863)
at org.springframework.integration.mail.ImapMailReceiver.searchForNewMessages(ImapMailReceiver.java:202)
at org.springframework.integration.mail.ImapMailReceiver.waitForNewMessages(ImapMailReceiver.java:167)
at org.springframework.integration.mail.ImapIdleChannelAdapter$IdleTask.run(ImapIdleChannelAdapter.java:220)
at org.springframework.integration.mail.ImapIdleChannelAdapter$ReceivingTask.run(ImapIdleChannelAdapter.java:190)
at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
at org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:81)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
更新
看起来这可能不得不处理已删除的消息,而不是从INBOX中清除bean。当我从桌面邮件客户端检查INBOX时,它在收件箱中显示6条消息,但是当我通过网络邮件登录邮件时,它显示了6封常用电子邮件,1条用一条线交叉,并注释了它们在说INBOX中有7条消息,其中1条被删除。一旦我从INBOX移动了该电子邮件,以前未处理的新邮件就会被spring-mail-integration检索到。
问题是,有没有办法通过spring-mail-integration设置改变这种行为,例如:忽略已删除但未清除的邮件?