public class ImapMailReceiver extends AbstractMailReceiver
MailReceiver
implementation for receiving mail messages from a
mail server that supports the IMAP protocol. In addition to the pollable
AbstractMailReceiver.receive()
method, the waitForNewMessages()
method provides
the option of blocking until new messages are available prior to calling
AbstractMailReceiver.receive()
. That option is only available if the server supports
the idle
command.DEFAULT_SI_USER_FLAG, folderOpenMode, initialized, logger
EXPRESSION_PARSER
Constructor and Description |
---|
ImapMailReceiver() |
ImapMailReceiver(java.lang.String url) |
Modifier and Type | Method and Description |
---|---|
java.lang.Boolean |
isShouldMarkMessagesAsRead()
Check if messages should be marked as read.
|
protected void |
onInit()
Subclasses may implement this for initialization logic.
|
protected javax.mail.Message[] |
searchForNewMessages()
Retrieves new messages from this receiver's folder.
|
protected void |
setAdditionalFlags(javax.mail.Message message)
Optional method allowing you to set additional flags.
|
void |
setCancelIdleInterval(long cancelIdleInterval)
IDLE commands will be terminated after this interval; useful in cases where a connection
might be silently dropped.
|
void |
setSearchTermStrategy(SearchTermStrategy searchTermStrategy)
Provides a way to set custom
SearchTermStrategy to compile a SearchTerm
to be applied when retrieving mail |
void |
setShouldMarkMessagesAsRead(java.lang.Boolean shouldMarkMessagesAsRead)
Specify if messages should be marked as read.
|
void |
waitForNewMessages()
This method is unique to the IMAP receiver and only works if IMAP IDLE
is supported (see RFC 2177 for more detail).
|
deleteMessages, destroy, fetchMessages, getFolder, getJavaMailProperties, getUserFlag, openFolder, receive, setEmbeddedPartsAsBytes, setHeaderMapper, setJavaMailAuthenticator, setJavaMailProperties, setMaxFetchSize, setProtocol, setSelectorExpression, setSession, setShouldDeleteMessages, setSimpleContent, setUserFlag, shouldDeleteMessages, toString
afterPropertiesSet, extractTypeIfPossible, getApplicationContext, getApplicationContextId, getBeanFactory, getChannelResolver, getComponentName, getComponentType, getConversionService, getExpression, getIntegrationProperties, getIntegrationProperty, getMessageBuilderFactory, getTaskScheduler, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentName, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskScheduler
public ImapMailReceiver()
public ImapMailReceiver(java.lang.String url)
public java.lang.Boolean isShouldMarkMessagesAsRead()
public void setSearchTermStrategy(SearchTermStrategy searchTermStrategy)
SearchTermStrategy
to compile a SearchTerm
to be applied when retrieving mailsearchTermStrategy
- The search term strategy implementation.public void setShouldMarkMessagesAsRead(java.lang.Boolean shouldMarkMessagesAsRead)
shouldMarkMessagesAsRead
- true if messages should be marked as read.public void setCancelIdleInterval(long cancelIdleInterval)
cancelIdleInterval
- the cancelIdleInterval to setprotected void onInit() throws java.lang.Exception
IntegrationObjectSupport
onInit
in class AbstractMailReceiver
java.lang.Exception
- Any exception.public void waitForNewMessages() throws javax.mail.MessagingException
javax.mail.MessagingException
- Any MessagingException.protected javax.mail.Message[] searchForNewMessages() throws javax.mail.MessagingException
SearchTerm
that searches for all messages in the
folder that are RECENT
, not
ANSWERED
, and not
DELETED
. The search term is used
to search
for new messages.searchForNewMessages
in class AbstractMailReceiver
javax.mail.MessagingException
- in case of JavaMail errorsprotected void setAdditionalFlags(javax.mail.Message message) throws javax.mail.MessagingException
AbstractMailReceiver
setAdditionalFlags
in class AbstractMailReceiver
message
- The message.javax.mail.MessagingException
- A MessagingException.