Chapter 10. The Timer Service

The timer service is a special-purpose notification broadcaster designed to send notifications at specific time intervals, starting at a particular date and time. Like the other agent services we have looked at, the timer service is required for all compliant JMX implementations. In addition, the timer service is an MBean, so it can be managed (although it does not have to be registered with the MBean server to be used). There are two primary uses of the timer service:

  • To send a single notification to all listeners interested in that notification type

  • To send multiple notifications that repeat at specific intervals for a set number of times, or indefinitely

The timer service is capable of sending any number of notifications at different intervals. Each notification that is to be sent by the timer service is given a notification type, defined by the agent that instructs the timer service to send that notification. In other words, unlike the monitoring services, the timer service does not send a predefined set of notification types. Instead, the agent tells the timer service what notification types to send, as well as when to start sending the notification, how many times the notification is to repeat, and the amount of time that is to elapse between each notification (for repeating notifications only, of course).

The timer service is implemented through the use of three classes:

Timer

The class that contains the implementation of the timer service ...

Get Java Management Extensions now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.