Class ImapMailReceiver
java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.mail.AbstractMailReceiver
org.springframework.integration.mail.ImapMailReceiver
- All Implemented Interfaces:
Aware,BeanFactoryAware,BeanNameAware,DisposableBean,InitializingBean,ApplicationContextAware,ExpressionCapable,MailReceiver,NamedComponent
A
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.- Author:
- Arjen Poutsma, Mark Fisher, Oleg Zhurakousky, Gary Russell, Artem Bilan, Alexander Pinske
-
Field Summary
Fields inherited from class org.springframework.integration.mail.AbstractMailReceiver
DEFAULT_SI_USER_FLAGFields inherited from class org.springframework.integration.context.IntegrationObjectSupport
EXPRESSION_PARSER, logger -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidThe hook to be called when we need to cancel the current ping task and close the mail folder.voiddestroy()Check if messages should be marked as read.protected voidonInit()Subclasses may implement this for initialization logic.protected Message[]Retrieves new messages from this receiver's folder.protected voidsetAdditionalFlags(Message message) Optional method allowing you to set additional flags.voidsetCancelIdleInterval(long cancelIdleInterval) IDLE commands will be terminated after this interval; useful in cases where a connection might be silently dropped.voidsetSearchTermStrategy(SearchTermStrategy searchTermStrategy) Provides a way to set customSearchTermStrategyto compile aSearchTermto be applied when retrieving mail.voidsetShouldMarkMessagesAsRead(Boolean shouldMarkMessagesAsRead) Specify if messages should be marked as read.voidThis method is unique to the IMAP receiver and only works if IMAP IDLE is supported (see RFC 2177 for more detail).Methods inherited from class org.springframework.integration.mail.AbstractMailReceiver
closeFolder, deleteMessages, fetchMessages, getFolder, getFolderOpenMode, getJavaMailProperties, getUserFlag, openFolder, receive, setAutoCloseFolder, setEmbeddedPartsAsBytes, setHeaderMapper, setJavaMailAuthenticator, setJavaMailProperties, setMaxFetchSize, setProtocol, setSelectorExpression, setSession, setShouldDeleteMessages, setSimpleContent, setUserFlag, shouldDeleteMessages, toStringMethods inherited from class org.springframework.integration.context.IntegrationObjectSupport
afterPropertiesSet, extractTypeIfPossible, generateId, getApplicationContext, getApplicationContextId, getBeanDescription, getBeanFactory, getBeanName, getChannelResolver, getComponentName, getComponentType, getConversionService, getExpression, getIntegrationProperties, getMessageBuilderFactory, getTaskScheduler, isInitialized, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentName, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskScheduler
-
Constructor Details
-
ImapMailReceiver
public ImapMailReceiver() -
ImapMailReceiver
-
-
Method Details
-
isShouldMarkMessagesAsRead
Check if messages should be marked as read.- Returns:
- true if messages should be marked as read.
-
setSearchTermStrategy
Provides a way to set customSearchTermStrategyto compile aSearchTermto be applied when retrieving mail.- Parameters:
searchTermStrategy- The search term strategy implementation.
-
setShouldMarkMessagesAsRead
Specify if messages should be marked as read.- Parameters:
shouldMarkMessagesAsRead- true if messages should be marked as read.
-
setCancelIdleInterval
public void setCancelIdleInterval(long cancelIdleInterval) IDLE commands will be terminated after this interval; useful in cases where a connection might be silently dropped. A new IDLE will usually immediately be processed. Specified in seconds; default 120 (2 minutes). RFC 2177 recommends an interval no larger than 29 minutes.- Parameters:
cancelIdleInterval- the cancelIdleInterval to set- Since:
- 3.0.5
-
onInit
protected void onInit()Description copied from class:IntegrationObjectSupportSubclasses may implement this for initialization logic.- Overrides:
onInitin classAbstractMailReceiver
-
destroy
public void destroy()- Specified by:
destroyin interfaceDisposableBean- Overrides:
destroyin classAbstractMailReceiver
-
cancelPing
public void cancelPing()The hook to be called when we need to cancel the current ping task and close the mail folder. In other words: when IMAP idle should be stopped for some reason. The nextwaitForNewMessages()call will re-open the folder and start a new ping task.- Since:
- 5.2
-
waitForNewMessages
This method is unique to the IMAP receiver and only works if IMAP IDLE is supported (see RFC 2177 for more detail).- Throws:
MessagingException- Any MessagingException.
-
searchForNewMessages
Retrieves new messages from this receiver's folder. This implementation creates aSearchTermthat searches for all messages in the folder that areRECENT, notANSWERED, and notDELETED. The search term is used tosearchfor new messages.- Specified by:
searchForNewMessagesin classAbstractMailReceiver- Returns:
- the new messages
- Throws:
MessagingException- in case of JavaMail errors
-
setAdditionalFlags
Description copied from class:AbstractMailReceiverOptional method allowing you to set additional flags. Currently only implemented in IMapMailReceiver.- Overrides:
setAdditionalFlagsin classAbstractMailReceiver- Parameters:
message- The message.- Throws:
MessagingException- A MessagingException.
-