I am connecting Office 365 mailbox using java mail API with IMAP protocol.
We have continuous stream of messages to mailbox and reading those through java mail API. Once messages are read, those will be moved to other folder or deleted. After successful move/delete of a batch I am doing expunge on INBOX folder.
The above functionality is doing good for around 72 hours and then EXPUNGE command is continuously failing. Following is the exception observed
javax.mail.MessagingException: A447 NO EXPUNGE failed.; nested exception is: com.sun.mail.iap.CommandFailedException: A447 NO EXPUNGE failed. at com.sun.mail.imap.IMAPFolder.expunge(IMAPFolder.java:2190) at com.sun.mail.imap.IMAPFolder.expunge(IMAPFolder.java:2151) at com.eiq.socvueportal.securitymonitoring.incidents.feeder.mail.IncidentsMailboxReader.expungeConnectionInbox(IncidentsMailboxReader.java:423) at com.eiq.socvueportal.securitymonitoring.incidents.feeder.mail.IncidentsMailboxReader.updateCompletedConnection(IncidentsMailboxReader.java:311) at com.eiq.socvueportal.securitymonitoring.incidents.feeder.mail.IncidentsMailboxReader.checkAndUpdateConnectionInstances(IncidentsMailboxReader.java:285) at com.eiq.socvueportal.securitymonitoring.incidents.feeder.mail.IncidentsMailboxReader.getUnreadIncidentMails(IncidentsMailboxReader.java:76) at com.eiq.socvueportal.securitymonitoring.incidents.feeder.worker.IncidentMailsProcessor.findAndProcessUnreadMails(IncidentMailsProcessor.java:200) at com.eiq.socvueportal.securitymonitoring.incidents.feeder.worker.IncidentMailsProcessor.run(IncidentMailsProcessor.java:85) 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) Caused by: com.sun.mail.iap.CommandFailedException: A447 NO EXPUNGE failed. at com.sun.mail.iap.Protocol.handleResult(Protocol.java:399) at com.sun.mail.iap.Protocol.simpleCommand(Protocol.java:425) at com.sun.mail.imap.protocol.IMAPProtocol.expunge(IMAPProtocol.java:1479) at com.sun.mail.imap.IMAPFolder.expunge(IMAPFolder.java:2183) ... 10 more
How can this be avoided? And at what scenarios this can be observed?