我正在使用javamail 1.5.5,我想在GMail邮箱中收听新邮件。
我在MessageAdded方法上有一个MessageCountListener的实现,最后我做了:
try {
// process new messages
idleManager.watch(ifo); // keep watching for new messages
} catch (MessagingException mex) {
logger.error(".....", mex);
}
我不确定是因为我得到了那个例外......
我相信我正在做的事情https://javamail.java.net/nonav/docs/api/com/sun/mail/imap/IdleManager.html#watch-javax.mail.Folder-
遵循一些邮件调试日志,考虑在该异常之后,没有新消息到达列表器。
DEBUG IMAP: IdleManager selected 1 channels
DEBUG IMAP: IdleManager selected folder: imaps://xxxxxxxxxx@imap.gmail.com:993/INBOX
* 1026 FETCH (UID 4284 FLAGS (\Answered \Seen))
DEBUG IMAP: IdleManager continue watching folder imaps://xxxxxxx@imap.gmail.com:993/INBOX
DEBUG IMAP: IdleManager adding imaps://xxxxxxxxx@imap.gmail.com:993/INBOX to selector
DEBUG IMAP: IdleManager waiting...
DEBUG IMAP: IdleManager selected 1 channels
DEBUG IMAP: IdleManager selected folder: imaps://xxxxxxxxxxx@imap.gmail.com:993/INBOX
DEBUG IMAP: handleIdle: set to RUNNING
DEBUG IMAP: IdleManager got exception for folder: imaps://prismatest@imap.gmail.com:993/INBOX, THROW:
javax.mail.FolderClosedException: * BYE JavaMail Exception: java.io.IOException: Connection dropped by server?
at com.sun.mail.imap.IMAPFolder.handleIdle(IMAPFolder.java:3199)
at com.sun.mail.imap.IdleManager.processKeys(IdleManager.java:370)
at com.sun.mail.imap.IdleManager.select(IdleManager.java:281)
at com.sun.mail.imap.IdleManager.access$200(IdleManager.java:137)
at com.sun.mail.imap.IdleManager$1.run(IdleManager.java:164)
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)
DEBUG IMAP: IdleManager waiting...
谢谢,再见