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
EXPRESSION_PARSER, logger
Constructor and Description |
---|
ImapMailReceiver() |
ImapMailReceiver(String url) |
Modifier and Type | Method and Description |
---|---|
void |
cancelPing()
The hook to be called when we need to cancel the current ping task and close the mail folder.
|
void |
destroy() |
Boolean |
isShouldMarkMessagesAsRead()
Check if messages should be marked as read.
|
protected void |
onInit()
Subclasses may implement this for initialization logic.
|
protected Message[] |
searchForNewMessages()
Retrieves new messages from this receiver's folder.
|
protected void |
setAdditionalFlags(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(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).
|
closeFolder, deleteMessages, fetchMessages, getFolder, getFolderOpenMode, getJavaMailProperties, getUserFlag, openFolder, receive, setAutoCloseFolder, setEmbeddedPartsAsBytes, setHeaderMapper, setJavaMailAuthenticator, setJavaMailProperties, setMaxFetchSize, setProtocol, setSelectorExpression, setSession, setShouldDeleteMessages, setSimpleContent, setUserFlag, shouldDeleteMessages, toString
afterPropertiesSet, extractTypeIfPossible, generateId, getApplicationContext, getApplicationContextId, getBeanDescription, getBeanFactory, getBeanName, getChannelResolver, getComponentName, getComponentType, getConversionService, getExpression, getIntegrationProperties, getIntegrationProperty, getMessageBuilderFactory, getTaskScheduler, isInitialized, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentName, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskScheduler
public ImapMailReceiver()
public ImapMailReceiver(String url)
public 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(Boolean shouldMarkMessagesAsRead)
shouldMarkMessagesAsRead
- true if messages should be marked as read.public void setCancelIdleInterval(long cancelIdleInterval)
cancelIdleInterval
- the cancelIdleInterval to setprotected void onInit()
IntegrationObjectSupport
onInit
in class AbstractMailReceiver
public void destroy()
destroy
in interface DisposableBean
destroy
in class AbstractMailReceiver
public void cancelPing()
waitForNewMessages()
call will re-open the folder and start a new ping task.public void waitForNewMessages() throws MessagingException
MessagingException
- Any MessagingException.protected Message[] searchForNewMessages() throws 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
MessagingException
- in case of JavaMail errorsprotected void setAdditionalFlags(Message message) throws MessagingException
AbstractMailReceiver
setAdditionalFlags
in class AbstractMailReceiver
message
- The message.MessagingException
- A MessagingException.