Previous Next vertical dots separating previous/next from contents/index/pdf

Overview: Timer Control

The timer control can notify a web service in the following ways:

  1. A specific (absolute) timeout has passed (e.g., January 23, 2012 midnight)
  2. A relative timeout has passed (e.g., an hour and seventeen minutes)
  3. A recurring time interval has elapsed (e.g., every 3 minutes)
  4. Both an intial timeout and a recurring interval (e.g., after one hour, every 5 minutes OR after January 1, 2010, every hour thereafter)

The timer control can perform only one of these tasks at a time. If you wish to do more than one timer task, you may create additional timer controls. Alternately, you may run a timer and on completion, change the timer settings and start the timer again.

If a timer is created with NO time specified, then it will perform the default timer--a relative timeout of 0 seconds.

All timer controls are instances of the com.bea.control.TimerControl base class or the com.bea.control.TimerControlBean base class. A timer control is declared directly in a .java file. Timer controls are based on the EJB 2.1 timer service. Timer controls make a best-effort to do a callback to the client when a timer elapses, suitable for application timers. However timer controls are not a true real-time time service. Timer controls are allowed only in conversational (stateful) web services.

Creating and Configuring a Basic Timer Control

To create a basic timer control, the IDE provides commands that will insert the declaration/annotation for a TimerControl into the code for your web service and set attributes.

To specify a relative timeout and/or recurring time, set the timer property values in the Annotations view.

To specify an absolute timeout, call the setTimeoutAt method on the timer control instance before starting the timer. You can also stop the timer, reset the absolute timeout value and start the timer again. If a recurring time value has been specified previously from Annotations view, the recurring timer begins after the initial absolute time has elapsed.

To define a payload to be returned on the callback, call the setPayload method in your web service before starting the timer.

To set other configuration values, you can use the Annotations view to set properties that optionally specify the type of timer intervals (coalesced vs. non-coalesced), whether the timer is transactional, and the JNDI Provider URL and Context Factory.

Setting up Web Service Operations to Access a Timer Control

To run the timer, once the timer has been declared and configured, you must create a conversational web service and then within your web service you create operations (web methods) that start/stop/restart the timer, based on the annotation settings or based on method calls. The timer control requires a stateful conversational web service, so the web methods must be set up appropriately.

To specify what happens when the timer elapses, you must set up an event handler in the web service to process callbacks.

Changing Timer Settings Dynamically

To change settings programatically, (other than the absolute timeout value), you must use TimerControlBean. The bean is generated by the Beehive control framework at build time and implements the TimerControl interface, providing additional properties and methods that allow you to control all of the properties in the Annotations view at run-time.

Related Topics

Using WebLogic System Controls

Timer Control

TimerControl Interface

Timer Control Reference

Tutorial: Creating a Web Service with Timer Control


Skip navigation bar   Back to Top