Version 5

    The TimerService


    Introduced in JBoss v4.0.3, the TimerService is a simple mbean that follows

    the JBoss ServiceLifecycle model and can be used to configure an external

    mbean, to produce periodically JMX notifications.


    By subscribing and reacting to those notification from a 3rd mbean, you can have

    a simple way of scheduling periodic tasks.


    The attributes that can be configured on the TimerService are shown below:


    • NotificationType: the type of the produced

    • NotificationMessage: the string message to put in the produced notifications

    • TimerPeriod: every how often to emit notifications, e.g. 500msec, 10sec, 5min, 1h.

      a zero value will produce just one notification

    • Repeatitions: how many timer notifications to emit when the period is not zero;

      a zero value produces infinite notifications

    • FixedRate: whether the periodic notifications should be produced at

      a FixedRate (true) or a FixedDelay (false, default) - since v4.0.5

    • TimerMBean: the ObjectName of the JMX Timer to configure; should be

      combined with a dependency.




    (taken from server/default/deploy/monitoring-service.xml)


    Configure a periodic 'heartbeat' timer notification to be emitted every 5 seconds.

    In this example we have inlined the creation of the Timer in the depends

    block, however, a single Timer could have been declared independently with

    multiple TimerService instances pointing to it.

      <mbean code=""
        <attribute name="NotificationType">jboss.monitor.heartbeat</attribute>
        <attribute name="NotificationMessage">JBoss is alive!</attribute>
        <attribute name="TimerPeriod">5sec</attribute>
        <depends optional-attribute-name="TimerMBean">
          <mbean code=""


    Seeing is believing


    If you want to see/log the emitted notifications from the above example,

    you can configure a NotificationListener as follows. (Note we subscribe

    to the Timer mbean not the TimerService!)

      <mbean code=""
        <attribute name="SubscriptionList">
            <mbean name="jboss.monitor:name=Heartbeat,type=Timer"></mbean>





    Referenced by: