public class PollingMonitoringStrategy extends AbstractMonitoringStrategy
MonitoringStrategy
interface that uses a simple polling mechanism. Defines a polling interval
property which defines the interval in between message polls.
Note that this implementation is not suitable for use with POP3 servers. Use the Pop3PollingMonitoringStrategy
instead.
Modifier and Type | Field and Description |
---|---|
static long |
DEFAULT_POLLING_FREQUENCY
Defines the default polling frequency.
|
logger
Constructor and Description |
---|
PollingMonitoringStrategy() |
Modifier and Type | Method and Description |
---|---|
protected void |
afterSleep(Folder folder)
Invoked after the
Thread.sleep(long) method has been invoked. |
void |
setPollingInterval(long pollingInterval)
Sets the interval used in between message polls, in milliseconds.
|
protected void |
waitForNewMessages(Folder folder)
Template method that blocks until new messages arrive in the given folder.
|
deleteMessages, fetchMessages, getFolderOpenMode, monitor, searchForNewMessages, setDeleteMessages
public static final long DEFAULT_POLLING_FREQUENCY
public void setPollingInterval(long pollingInterval)
protected void waitForNewMessages(Folder folder) throws MessagingException, InterruptedException
AbstractMonitoringStrategy
Thread.sleep(long)
or the IMAP IDLE command.waitForNewMessages
in class AbstractMonitoringStrategy
folder
- the folder to monitorMessagingException
- in case of JavaMail errorsInterruptedException
- when a thread is interruptedprotected void afterSleep(Folder folder) throws MessagingException
Thread.sleep(long)
method has been invoked. This implementation calls Folder.getMessageCount()
, to force new messages to be seen.folder
- the folder to check for new messagesMessagingException
- in case of JavaMail errors