An abstract implementation of AlarmChannel, to ease the creation of custom channels.
Defines a minResendInterval of 60 seconds.
Subclasses only need to implement the createSendTask(String) method, returning a new
Runnable in every call; this Runnable will be queued in a thread pool to be executed
as soon as possible, but without interrupting normal program flow.
This class already handles what is needed to avoid sending repeated messages very often.
Allow synchronous sending of alarms, if the thread pool for a channel rejects asynchronous
execution. Default is false.
public void setMinResendInterval(int millis)
Sets the minimum amount of time between equal messsages. The same message will not be sent through
the channel if it was last sent before this interval has elapsed, unless AlarmSender.sendAlways() is
public int getMinResendInterval()
Returns the minimum amount of time that must elapse before a previously sent alarm message can be
sent again. The interval is in milliseconds.
Sends an alarm message for the specified source. If the concrete subclass returns null from the
createSendTask(String, String) method, no alarm is sent, and no record is made of the
message's last time being sent.
source - The alarm source. A channel can send the alarm to different recipients depending on the source.
This parameter can be null, which means that it should be sent to the default recipients for the channel.
public void shutdown()
Shuts down the thread pool and rejects any more incoming alarms. Awaits up to 5 seconds to send out
any pending alarms.
Subclasses need to create and return a new Runnable in each call to this method. The returned
Runnable will be queued in a thread pool to avoid latency in the normal program flow.
If a subclass decides not to send the alarm message for some reason, it can return null so that nothing
msg - The message to be sent.
source - The alarm source. A channel can have different recipient lists depending on the alarm source.
This method is used to determine if a certain alarm channel has a special condition for the specified
alarmSource or not. It's used to determine if the alarm messages should be saved as regular alarms or
as messages for that specific source.