Я использую весеннюю загрузку 2.2.4-RELEASE и интеграцию Spring. Я разрабатываю простой ImapReceiver.
Мне нужно следующее:
- Я могу настроить несколько прослушивателей Imap (я использую DSL весенней интеграции)
- Я получаю MimeMessage
- Я получаю всю информацию и вложения
- Я обрабатываю эту информацию и вложения, помещая их в БД и Alfresco
Я написал следующее code
ImapIdleChannelAdapterSpec imapIdleChannelAdapterSpec = Mail.imapIdleAdapter(connectionUrl.toString())
.javaMailProperties(javaMailProperties)
.shouldDeleteMessages(deleteMessages)
.shouldMarkMessagesAsRead(markMessagesRead)
.autoStartup(true)
.autoCloseFolder(true)
.id(confMailIn.getHost() + "_adapter")
.selector(selectFunction);
if (confMailIn.isRichiedeAutenticazione()) {
imapIdleChannelAdapterSpec = imapIdleChannelAdapterSpec.javaMailAuthenticator(new CasellaPostaleAuthenticator(cpd.getIndirizzoMail(), cpd.getUsername(), cpd.getPassword()));
}
flow = IntegrationFlows
.from(imapIdleChannelAdapterSpec)
.handle(message ->{
publishMailEvent(message);
})
.get();
Метод publishMailEvent извлекает всю необходимую информацию (например, TO, CC, B CC, тему письма, вложения) и генерирует пользовательское событие asyn c.
Теперь, если я уйду autoCloseFolder(true)
, я не смогу обработать сообщение, потому что получаю исключение FolderClosedException. Если я установил autoCloseFolder(false)
, все работает, но я вижу бесконечную печать
2020-03-06 10:24:37,580 141381 [asyncTaskExecutor-18] DEBUG i.e.t.r.p.w.b.h.MailMessageHandler - Header name Message-ID header value <opec292.20200306102349.32719.160.1.254.63@pec.aruba.it>
2020-03-06 10:24:37,582 141383 [asyncTaskExecutor-12] TRACE i.e.t.r.p.w.b.h.MailMessageHandler - Aggiungo allegato smime.p7s all'elenco di allegati
2020-03-06 10:24:37,583 141384 [asyncTaskExecutor-18] TRACE i.e.t.r.p.w.b.h.MailMessageHandler - Aggiungo allegato smime.p7s all'elenco di allegati
2020-03-06 10:24:37,583 141384 [asyncTaskExecutor-15] TRACE i.e.t.r.p.w.b.h.MailMessageHandler - Aggiungo allegato smime.p7s all'elenco di allegati
2020-03-06 10:24:37,607 141408 [asyncTaskExecutor-18] TRACE i.e.t.r.p.w.b.s.i.GestioneMailSvcImpl - Mail out con id messaggio <opec292.20200306102349.32719.160.1.254.63@pec.aruba.it> esistente ? false
2020-03-06 10:24:37,607 141408 [asyncTaskExecutor-12] TRACE i.e.t.r.p.w.b.s.i.GestioneMailSvcImpl - Mail out con id messaggio <opec292.20200306102349.32719.160.1.63@pec.aruba.it> esistente ? false
2020-03-06 10:24:37,607 141408 [asyncTaskExecutor-15] TRACE i.e.t.r.p.w.b.s.i.GestioneMailSvcImpl - Mail out con id messaggio <opec292.20200306102350.04933.324.2.326.71@pec.aruba.it> esistente ? false
2020-03-06 17:19:33,850 140094 [scheduling-1] INFO o.s.i.mail.ImapMailReceiver - attempting to receive mail from folder [INBOX]
2020-03-06 17:19:33,938 140182 [scheduling-1] INFO o.s.i.mail.ImapMailReceiver - attempting to receive mail from folder [INBOX]
2020-03-06 17:19:34,021 140265 [scheduling-1] INFO o.s.i.mail.ImapMailReceiver - attempting to receive mail from folder [INBOX]
2020-03-06 17:19:34,107 140351 [scheduling-1] INFO o.s.i.mail.ImapMailReceiver - attempting to receive mail from folder [INBOX]
2020-03-06 17:19:34,190 140434 [scheduling-1] INFO o.s.i.mail.ImapMailReceiver - attempting to receive mail from folder [INBOX]
2020-03-06 17:19:34,276 140520 [scheduling-1] INFO o.s.i.mail.ImapMailReceiver - attempting to receive mail from folder [INBOX]
2020-03-06 17:19:34,362 140606 [scheduling-1] INFO o.s.i.mail.ImapMailReceiver - attempting to receive mail from folder [INBOX]
2020-03-06 17:19:34,453 140697 [scheduling-1] INFO o.s.i.mail.ImapMailReceiver - attempting to receive mail from folder [INBOX]
2020-03-06 17:19:34,537 140781 [scheduling-1] INFO o.s.i.mail.ImapMailReceiver - attempting to receive mail from folder [INBOX]
2020-03-06 17:19:34,621 140865 [scheduling-1] INFO o.s.i.mail.ImapMailReceiver - attempting to receive mail from folder [INBOX]
2020-03-06 17:19:34,703 140947 [scheduling-1] INFO o.s.i.mail.ImapMailReceiver - attempting to receive mail from folder [INBOX]
2020-03-06 17:19:34,788 141032 [scheduling-1] INFO o.s.i.mail.ImapMailReceiver - attempting to receive mail from folder [INBOX]
2020-03-06 17:19:34,874 141118 [scheduling-1] INFO o.s.i.mail.ImapMailReceiver - attempting to receive mail from folder [INBOX]
2020-03-06 17:19:34,960 141204 [scheduling-1] INFO o.s.i.mail.ImapMailReceiver - attempting to receive mail from folder [INBOX]
2020-03-06 17:19:35,051 141295 [scheduling-1] INFO o.s.i.mail.ImapMailReceiver - attempting to receive mail from folder [INBOX]
2020-03-06 17:19:35,133 141377 [scheduling-1] INFO o.s.i.mail.ImapMailReceiver - attempting to receive mail from folder [INBOX]
2020-03-06 17:19:35,216 141460 [scheduling-1] INFO o.s.i.mail.ImapMailReceiver - attempting to receive mail from folder [INBOX]
2020-03-06 17:19:35,301 141545 [scheduling-1] INFO o.s.i.mail.ImapMailReceiver - attempting to receive mail from folder [INBOX]
2020-03-06 17:19:35,386 141630 [scheduling-1] INFO o.s.i.mail.ImapMailReceiver - attempting to receive mail from folder [INBOX]
2020-03-06 17:19:35,468 141712 [scheduling-1] INFO o.s.i.mail.ImapMailReceiver - attempting to receive mail from folder [INBOX]
2020-03-06 17:19:35,553 141797 [scheduling-1] INFO o.s.i.mail.ImapMailReceiver - attempting to receive mail from folder [INBOX]
2020-03-06 17:19:35,635 141879 [scheduling-1] INFO o.s.i.mail.ImapMailReceiver - attempting to receive mail from folder [INBOX]
2020-03-06 17:19:35,718 141962 [scheduling-1] INFO o.s.i.mail.ImapMailReceiver - attempting to receive mail from folder [INBOX]
2020-03-06 17:19:35,801 142045 [scheduling-1] INFO o.s.i.mail.ImapMailReceiver - attempting to receive mail from folder [INBOX]
2020-03-06 17:19:35,885 142129 [scheduling-1] INFO o.s.i.mail.ImapMailReceiver - attempting to receive mail from folder [INBOX]
2020-03-06 17:19:35,976 142220 [scheduling-1] INFO o.s.i.mail.ImapMailReceiver - attempting to receive mail from folder [INBOX]
2020-03-06 17:19:36,062 142306 [scheduling-1] INFO o.s.i.mail.ImapMailReceiver - attempting to receive mail from folder [INBOX]
2020-03-06 17:19:36,145 142389 [scheduling-1] INFO o.s.i.mail.ImapMailReceiver - attempting to receive mail from folder [INBOX]
2020-03-06 17:19:36,233 142477 [scheduling-1] INFO o.s.i.mail.ImapMailReceiver - attempting to receive mail from folder [INBOX]
2020-03-06 17:19:36,324 142568 [scheduling-1] INFO o.s.i.mail.ImapMailReceiver - attempting to receive mail from folder [INBOX]
2020-03-06 17:19:36,410 142654 [scheduling-1] INFO o.s.i.mail.ImapMailReceiver - attempting to receive mail from folder [INBOX]
2020-03-06 17:19:36,493 142737 [scheduling-1] INFO o.s.i.mail.ImapMailReceiver - attempting to receive mail from folder [INBOX]
2020-03-06 17:19:36,574 142818 [scheduling-1] INFO o.s.i.mail.ImapMailReceiver - attempting to receive mail from folder [INBOX]
2020-03-06 17:19:36,656 142900 [scheduling-1] INFO o.s.i.mail.ImapMailReceiver - attempting to receive mail from folder [INBOX]
2020-03-06 17:19:36,743 142987 [scheduling-1] INFO o.s.i.mail.ImapMailReceiver - attempting to receive mail from folder [INBOX]
2020-03-06 17:19:36,831 143075 [scheduling-1] INFO o.s.i.mail.ImapMailReceiver - attempting to receive mail from folder [INBOX]
2020-03-06 17:19:36,918 143162 [scheduling-1] INFO o.s.i.mail.ImapMailReceiver - attempting to receive mail from folder [INBOX]
2020-03-06 17:19:37,000 143244 [scheduling-1] INFO o.s.i.mail.ImapMailReceiver - attempting to receive mail from folder [INBOX]
2020-03-06 17:19:37,083 143327 [scheduling-1] INFO o.s.i.mail.ImapMailReceiver - attempting to receive mail from folder [INBOX]
2020-03-06 17:19:37,165 143409 [scheduling-1] INFO o.s.i.mail.ImapMailReceiver - attempting to receive mail from folder [INBOX]
2020-03-06 17:19:37,247 143491 [scheduling-1] INFO o.s.i.mail.ImapMailReceiver - attempting to receive mail from folder [INBOX]
2020-03-06 17:19:37,333 143577 [scheduling-1] INFO o.s.i.mail.ImapMailReceiver - attempting to receive mail from folder [INBOX]
2020-03-06 17:19:37,431 143675 [scheduling-1] INFO o.s.i.mail.ImapMailReceiver - attempting to receive mail from folder [INBOX]
2020-03-06 17:19:37,521 143765 [scheduling-1] INFO o.s.i.mail.ImapMailReceiver - attempting to receive mail from folder [INBOX]
2020-03-06 17:19:37,609 143853 [scheduling-1] INFO o.s.i.mail.ImapMailReceiver - attempting to receive mail from folder [INBOX]
2020-03-06 17:19:37,699 143943 [scheduling-1] INFO o.s.i.mail.ImapMailReceiver - attempting to receive mail from folder [INBOX]
2020-03-06 17:19:37,806 144050 [scheduling-1] INFO o.s.i.mail.ImapMailReceiver - attempting to receive mail from folder [INBOX]
2020-03-06 17:19:37,897 144141 [scheduling-1] INFO o.s.i.mail.ImapMailReceiver - attempting to receive mail from folder [INBOX]
2020-03-06 17:19:37,993 144237 [scheduling-1] INFO o.s.i.mail.ImapMailReceiver - attempting to receive mail from folder [INBOX]
2020-03-06 17:19:38,079 144323 [scheduling-1] INFO o.s.i.mail.ImapMailReceiver - attempting to receive mail from folder [INBOX]
2020-03-06 17:19:38,181 144425 [scheduling-1] INFO o.s.i.mail.ImapMailReceiver - attempting to receive mail from folder [INBOX]
2020-03-06 17:19:38,263 144507 [scheduling-1] INFO o.s.i.mail.ImapMailReceiver - attempting to receive mail from folder [INBOX]
2020-03-06 17:19:38,346 144590 [scheduling-1] INFO o.s.i.mail.ImapMailReceiver - attempting to receive mail from folder [INBOX]
Более того, я не могу понять, когда закрыть папку. Я могу получить доступ к ресурсу Closeable, но когда мне закрывать папку? Если я закрою его сразу после генерации события, в следующем сообщении я снова получу FolderClosedException.
Может кто-нибудь дать мне совет, чтобы понять, как лучше всего справиться с тем, что мне нужно?
Спасибо
Анджело