Package com.storedobject.telegram
Class Server
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidThis method is invoked when this job is executed for the first time, and it will be invoked only once.booleanisActive()Check if the Job is still active or not.protected voidrecover()This method is invoked when the sender was stopped due to any error.protected intsendMessage(Telegram message) Send a message.protected voidThis 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:MessageSenderThis 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:
initializein classMessageSender<Telegram>
-
recover
protected void recover()Description copied from class:MessageSenderThis method is invoked when the sender was stopped due to any error. Make sure thatDaemonJob.isActive()method returnsfalseto indicate that the sender had stopped with some error condition. All recovery action should happen here and theDaemonJob.isActive()method should returntrueafter this. Otherwise, no messages will be sent by invoking theMessageSender.sendMessage(Message)method.- Overrides:
recoverin classMessageSender<Telegram>
-
terminate
protected void terminate()Description copied from class:MessageSenderThis method is invoked when the sender needs to be shut down. This will be invoked only once.- Overrides:
terminatein classMessageSender<Telegram>
-
isActive
public boolean isActive()Description copied from class:DaemonJobCheck 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:MessageSenderSend a message. The method should just send the message and should not update any status.- Specified by:
sendMessagein 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).
-