Package com.storedobject.telegram
Class Server
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
This method is invoked when this job is executed for the first time, and it will be invoked only once.boolean
isActive()
Check if the Job is still active or not.protected void
recover()
This method is invoked when the sender was stopped due to any error.protected int
sendMessage
(Telegram message) Send a message.protected void
This method is invoked when the sender needs to be shut down.Methods inherited from class com.storedobject.job.MessageSender
canSend, execute, getBatchSize, getCreditBalance, getDeliveryCost, getSelectCondition, kick, monitorDeliveryCost, sendMessages, shutdown
-
Constructor Details
-
Server
-
-
Method Details
-
initialize
protected void initialize()Description copied from class:MessageSender
This method is invoked when this job is executed for the first time, and it will be invoked only once. You may set up the sender here.- Overrides:
initialize
in classMessageSender<Telegram>
-
recover
protected void recover()Description copied from class:MessageSender
This method is invoked when the sender was stopped due to any error. Make sure thatDaemonJob.isActive()
method returnsfalse
to indicate that the sender had stopped with some error condition. All recovery action should happen here and theDaemonJob.isActive()
method should returntrue
after this. Otherwise, no messages will be sent by invoking theMessageSender.sendMessage(Message)
method.- Overrides:
recover
in classMessageSender<Telegram>
-
terminate
protected void terminate()Description copied from class:MessageSender
This method is invoked when the sender needs to be shut down. This will be invoked only once.- Overrides:
terminate
in classMessageSender<Telegram>
-
isActive
public boolean isActive()Description copied from class:DaemonJob
Check if the Job is still active or not. (The default implementation always returnstrue
). If this method returnsfalse
, the Job Scheduler will invoke theJob.execute()
method again when it is due for the next run. -
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<Telegram>
- 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
).
-