+

Search Tips   |   Advanced Search

Alarms

An alarm runs JEE context-aware code at a given time interval. Alarm objects are fine-grained, nonpersistent, transient, and can fire at millisecond intervals.

Alarms are run using a thread pool associated with the work manager that owns the associated asynchronous scope. Create a work manager instance to create an alarm. Refer to the Configuring work managers topic for more information.

The AlarmManager.createAlarm() method takes an application-written object that implements the AlarmListener interface. For more information on the AlarmListener interface, refer to the generated API documentation. The fired method is called when the alarm expires. The createAlarm() method returns a non-serializable handle, which can be used to cancel or reset the alarm. All of the pending alarms are cancelled when its associated AsynchScope object is destroyed.

Best practice: The Java SE Development Kit 6 (JDK6 )already has a timer mechanism, so why create a new one? The JDK 6 is a Java SE feature that knows nothing about the Java EE environment. Timers fired by the Java SE feature do not run on a managed thread and are therefore unusable inside an application server. These timers also lack a Java EE context (that is, a java:comp value) and are not authenticated when they fire. The asynchronous scope alarms are fully supported by the product and have the same properties as any other asynchronous bean.best-practices


Alarm performance

The alarm subsystem is designed to handle a large number of alarms. However, do not expect alarms to process heavy loads when they are firing because this activity slows the processing of later alarms. If an alarm needs to process a heavy load, design a work object that is activated by a work manager. This procedure moves the heavy processing to a different thread and enables the alarm threads to process alarms unhampered. All of the alarms owned by asynchronous scopes that are owned by a single work manager share a common thread pool. The properties of this thread pool can be tuned at the work manager level using the administrative console.


Related concepts

  • Asynchronous scopes


    Related tasks

  • Develop asynchronous scopes
  • Configure work managers

  • Programming Interfaces APIs Concept topic