Class CompositeMailDispatcher

java.lang.Object
com.onec.mail.dispatch.CompositeMailDispatcher
All Implemented Interfaces:
MailDispatcher

public class CompositeMailDispatcher extends Object implements MailDispatcher
Failover dispatcher (provider=failover). Tries an ordered list of delegate providers, moving to the next only when the current one throws. Succeeds as soon as one delegate accepts the message; throws MailDeliveryException (carrying the last failure) only if every delegate fails.
  • Constructor Details

    • CompositeMailDispatcher

      public CompositeMailDispatcher(List<MailDispatcher> delegates)
  • Method Details

    • name

      public String name()
      Description copied from interface: MailDispatcher
      Stable provider id, e.g. "smtp", "sendgrid", "ses".
      Specified by:
      name in interface MailDispatcher
    • dispatch

      public void dispatch(MailMessage message)
      Description copied from interface: MailDispatcher
      Synchronously deliver a message to the provider. Throws MailDeliveryException on failure.
      Specified by:
      dispatch in interface MailDispatcher