Class PollingMonitoringStrategy

java.lang.Object
org.springframework.ws.transport.mail.monitor.AbstractMonitoringStrategy
org.springframework.ws.transport.mail.monitor.PollingMonitoringStrategy
All Implemented Interfaces:
MonitoringStrategy
Direct Known Subclasses:
Pop3PollingMonitoringStrategy

public class PollingMonitoringStrategy extends AbstractMonitoringStrategy
Implementation of the 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.

Since:
1.5.0
Author:
Arjen Poutsma
  • Field Details

    • DEFAULT_POLLING_FREQUENCY

      public static final long DEFAULT_POLLING_FREQUENCY
      Defines the default polling frequency. Set to 1000 * 60 milliseconds (i.e. 1 minute).
      See Also:
  • Constructor Details

    • PollingMonitoringStrategy

      public PollingMonitoringStrategy()
  • Method Details

    • setPollingInterval

      public void setPollingInterval(long pollingInterval)
      Sets the interval used in between message polls, in milliseconds. The default is 1000 * 60 ms, that is 1 minute.
    • waitForNewMessages

      protected void waitForNewMessages(jakarta.mail.Folder folder) throws jakarta.mail.MessagingException, InterruptedException
      Description copied from class: AbstractMonitoringStrategy
      Template method that blocks until new messages arrive in the given folder. Typical implementations use Thread.sleep(long) or the IMAP IDLE command.
      Specified by:
      waitForNewMessages in class AbstractMonitoringStrategy
      Parameters:
      folder - the folder to monitor
      Throws:
      jakarta.mail.MessagingException - in case of JavaMail errors
      InterruptedException - when a thread is interrupted
    • afterSleep

      protected void afterSleep(jakarta.mail.Folder folder) throws jakarta.mail.MessagingException
      Invoked after the Thread.sleep(long) method has been invoked. This implementation calls Folder.getMessageCount(), to force new messages to be seen.
      Parameters:
      folder - the folder to check for new messages
      Throws:
      jakarta.mail.MessagingException - in case of JavaMail errors