public class BatchEmailListener extends GenericService implements EmailListener, Schedulable
Two properties control how often the batch sends are
performed - maxBatchSize
and
sendSchedule
. If maxBatchSize
is
specified, a send is performed whenever the number of
batched email events reaches maxBatchSize
.
Also, if sendSchedule
is specified, sends are
performed according to the schedule. At least one of
these properties must be specified for the service to
function properly.
Since the sendEmailEvent
method may result
in a batch send of all the collected events (if the number
of events reaches maxBatchSize
), you should not
use the BatchEmailListener service directly, but rather in
conjunction with the EmailListenerQueue (i.e., configure
the EmailListenerQueue to have BatchEmailListener as a
listener).
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CLASS_VERSION
Class version string
|
SERVICE_INFO_KEY
DEFAULT_LOG_TRACE_STATUS
DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS
Constructor and Description |
---|
BatchEmailListener() |
Modifier and Type | Method and Description |
---|---|
void |
clearDeadEmailEvents()
Clears the current dead email queue
|
void |
doStartService()
Called after the service has been created, placed into the
naming hierarchy, and initialized with its configured property
values.
|
void |
doStopService()
Called when the service is required to shut down.
|
Schedule |
getClearDeadEmailSchedule()
Returns the Schedule for clearing the Dead Email Queue.
|
int |
getDeadEmailCount()
Gets the number of dead letters (letters that couldn't be sent
due to errors)
|
java.util.Dictionary |
getDeadEmailDictionary()
Returns a Dictionary object with each row
consisting of an undelivered EmailEvent and its
corresponding EmailException
|
java.util.Enumeration |
getDeadEmailEvents()
Returns an Enumeration of undelivered EmailEvent objects
|
java.util.Enumeration |
getDeadEmailExceptions()
Returns an Enumeration of EmailExceptions that belong
to undelivered EmailEvents
|
EmailMessageSender |
getEmailMessageSender()
Returns the EmailMessageSender used to send email.
|
int |
getMaxBatchSize()
Returns the maximum number of EmailEvents that will be
batched before a send is performed.
|
Scheduler |
getScheduler()
Returns the Scheduler responsible for scheduling batch
sends.
|
Schedule |
getSendSchedule()
Returns the Schedule for perfoming batch sends.
|
boolean |
isCollectDeadEmail() |
void |
performScheduledTask(Scheduler pScheduler,
ScheduledJob pJob)
Called when a scheduled job tied to this object occurs.
|
void |
sendDeadEmail()
Sends all of the email currently in the dead letter queue.
|
void |
sendEmailEvent(EmailEvent pEvent)
Adds the given email event to the internal batch queue.
|
void |
setClearDeadEmailSchedule(Schedule pClearDeadEmailSchedule)
Sets the Schedule for clearing the Dead Email Queue.
|
void |
setCollectDeadEmail(boolean p) |
void |
setEmailMessageSender(EmailMessageSender pSender)
Sets the EmailMessageSender used to send email.
|
void |
setMaxBatchSize(int pMaxBatchSize)
Sets the maximum number of EmailEvents that will be
batched before a send is performed.
|
void |
setScheduler(Scheduler pScheduler)
Sets the Scheduler responsible for scheduling batch sends.
|
void |
setSendSchedule(Schedule pSendSchedule)
Sets the Schedule for perfoming batch sends.
|
addLogListener, createAdminServlet, getAbsoluteName, getAdminServlet, getAdminServletOutputStreamEncoding, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isAdminServletUseServletOutputStream, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, reResolveThis, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setAdminServletOutputStreamEncoding, setAdminServletUseServletOutputStream, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogDebugTrace, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning
public EmailMessageSender getEmailMessageSender()
public void setEmailMessageSender(EmailMessageSender pSender)
public int getMaxBatchSize()
public void setMaxBatchSize(int pMaxBatchSize)
public Scheduler getScheduler()
public void setScheduler(Scheduler pScheduler)
public Schedule getSendSchedule()
public void setSendSchedule(Schedule pSendSchedule)
public Schedule getClearDeadEmailSchedule()
public void setClearDeadEmailSchedule(Schedule pClearDeadEmailSchedule)
public void setCollectDeadEmail(boolean p)
public boolean isCollectDeadEmail()
public int getDeadEmailCount()
public java.util.Dictionary getDeadEmailDictionary()
public java.util.Enumeration getDeadEmailEvents()
public java.util.Enumeration getDeadEmailExceptions()
public void clearDeadEmailEvents()
public void sendDeadEmail()
getDeadEmailDictionary
or
getDeadEmailExceptions
method to examine the reason
why the email wasn't sent before using this method.public void sendEmailEvent(EmailEvent pEvent) throws EmailException
maxBatchSize
,
this also causes all the collected events to be sent as
email messages.sendEmailEvent
in interface EmailListener
EmailException
public void performScheduledTask(Scheduler pScheduler, ScheduledJob pJob)
performScheduledTask
in interface Schedulable
pScheduler
- calling the jobpJob
- the ScheduledJobpublic void doStartService() throws ServiceException
doStartService
in class GenericService
ServiceException
- if the service had a problem
starting uppublic void doStopService() throws ServiceException
doStopService
in class GenericService
ServiceException
- if the service had a problem
shutting down