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 SummaryFields inherited from class org.springframework.integration.mail.AbstractMailReceiverDEFAULT_SI_USER_FLAGFields inherited from class org.springframework.integration.context.IntegrationObjectSupportEXPRESSION_PARSER, logger
- 
Constructor SummaryConstructors
- 
Method SummaryModifier 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.AbstractMailReceivercloseFolder, 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.IntegrationObjectSupportafterPropertiesSet, 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- 
ImapMailReceiverpublic ImapMailReceiver()
- 
ImapMailReceiver
 
- 
- 
Method Details- 
isShouldMarkMessagesAsReadCheck if messages should be marked as read.- Returns:
- true if messages should be marked as read.
 
- 
setSearchTermStrategyProvides a way to set customSearchTermStrategyto compile aSearchTermto be applied when retrieving mail.- Parameters:
- searchTermStrategy- The search term strategy implementation.
 
- 
setShouldMarkMessagesAsReadSpecify if messages should be marked as read.- Parameters:
- shouldMarkMessagesAsRead- true if messages should be marked as read.
 
- 
setCancelIdleIntervalpublic 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
 
- 
onInitprotected void onInit()Description copied from class:IntegrationObjectSupportSubclasses may implement this for initialization logic.- Overrides:
- onInitin class- AbstractMailReceiver
 
- 
destroypublic void destroy()- Specified by:
- destroyin interface- DisposableBean
- Overrides:
- destroyin class- AbstractMailReceiver
 
- 
cancelPingpublic 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
 
- 
waitForNewMessagesThis 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.
 
- 
searchForNewMessagesRetrieves 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 class- AbstractMailReceiver
- Returns:
- the new messages
- Throws:
- MessagingException- in case of JavaMail errors
 
- 
setAdditionalFlagsDescription copied from class:AbstractMailReceiverOptional method allowing you to set additional flags. Currently only implemented in IMapMailReceiver.- Overrides:
- setAdditionalFlagsin class- AbstractMailReceiver
- Parameters:
- message- The message.
- Throws:
- MessagingException- A MessagingException.
 
 
-