I spend day trying to find some explanation this exception. I try to configure ImapMailReceiver and ImapIdleChannelAdapter programmatic.
I didn\'t find any tutorials abo
You should call imapMailReceiver.afterPropertiesSet()
, which switches this.folderOpenMode = Folder.READ_WRITE;
. In your case it looks lie here:
imapMailReceiver.setJavaMailAuthenticator(new Authenticator() {
...
});
imapMailReceiver.afterPropertiesSet();
Actually almost all Spring Integration components should be configured as Spring beans and Container will take care about their initialization. The new 4.0 version provides enough options for JavaConfig: https://spring.io/blog/2014/04/30/spring-integration-4-0-released .
It's not clear to me why by default it is Folder.READ_ONLY
and there is no setter on the matter.
Feel free to raise a JIRA issue: https://jira.spring.io/browse/INT
In which case I should use ImapIdleChannelAdapter and when just Session for getting store and connecting to mailbox.
Actually it depends on your Mail provider. Spring Integration provides two components: Pop3MailReceiver
and ImapMailReceiver
. Of course Imap is better, because it doesn't fetch messages to the local directory and supports Listener
. Pop3 you should ping periodically.