Package com.storedobject.mail
Class Server
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected int
Batch size - How many messages to be read for sending in one batch?protected String
Additional condition to be be added when messages are read for sending.protected int
sendMessage
(Mail message) Send a message.protected boolean
sendMessages
(List<Mail> messages) Send a batch of messages.Methods inherited from class com.storedobject.job.MessageSender
canSend, execute, getCreditBalance, getDeliveryCost, initialize, kick, monitorDeliveryCost, recover, shutdown, terminate
-
Constructor Details
-
Server
-
-
Method Details
-
sendMessage
Description copied from class:MessageSender
Send a message. The method should just send the message and should not update any status.- Specified by:
sendMessage
in classMessageSender<Mail>
- Parameters:
message
- Message to send.- Returns:
- The error code to indicate the status. 0: Successful, 1: Retry later, 2: Insufficient balance. Anything
above 2 indicates an error condition that doesn't allow this message to be sent (for example, invalid mobile
number in case of an
SMSMessage
).
-
getBatchSize
protected int getBatchSize()Description copied from class:MessageSender
Batch size - How many messages to be read for sending in one batch?- Overrides:
getBatchSize
in classMessageSender<Mail>
- Returns:
- Default is 50.
-
sendMessages
Description copied from class:MessageSender
Send a batch of messages. The default implementation of this method processes each message by invokingMessageSender.sendMessage(Message)
and if this is overridden, theMessageSender.sendMessage(Message)
will not be invoked from elsewhere.Note: The Status of the message should be updated adn saved within this method if overridden.
- Overrides:
sendMessages
in classMessageSender<Mail>
- Parameters:
messages
- Messages to be sent.- Returns:
- True if messages are sent successfully.
-
getSelectCondition
Description copied from class:MessageSender
Additional condition to be be added when messages are read for sending.- Overrides:
getSelectCondition
in classMessageSender<Mail>
- Returns:
- Default implementation returns null, so no additional selection criteria are applied.
-