Receiving scheduler notifications

Why and when to perform this task

Various notification events are generated by a scheduler when it performs an operation on a task. These events include:

Scheduled
A task has been scheduled.
Purged
A task has been permanently deleted from the persistent store.
Suspended
A task was suspended.
Resumed
A task was resumed.
Complete
A task has run completely. If it was a repeating task, all repeats have been performed.
Cancelled
A task has been cancelled. It will not run again.
Fired
A task fired successfully.
Fire Failed
A task could not fire successfully.

To receive notification events, call the setNotificationSink() method on the TaskInfo interface before creating the event. The setNotificationSink() method enables you to specify the session bean that is to act as the callback, and a mask that restricts which events are generated.

Steps for this task

  1. Create a notification sink session bean.
    Create a stateless session bean that implements the handleEvent() method in the com.ibm.websphere.scheduler.NotificationSink remote interface. The handleEvent() method is called when the notification is fired. The Home and Remote interfaces can be set as follows in the bean's deployment descriptor:
    com.ibm.websphere.scheduler.NotificationSinkHome
    com.ibm.websphere.scheduler.NotificationSink
    The notification sink bean must exist in the same application (EAR file) that is used to create the task.
    The NotificationSink interface defines the following method:
    public void handleEvent(TaskNotificationInfo task) throws java.rmi.RemoteException; 
    The transactional context used by the session bean is defined by the assembler.
  2. Specify the notification sink session bean to be used as the callback.
    The following code illustrates how to set this option:
    TaskInfo taskInfo = ...
    Object o = new InitialContext().lookup("java:comp/env/ejb/NotificationSink");
    NotificationSinkHome home = (NotificationSinkHome )javax.rmi.PortableRemoteObject.narrow(o,NotificationSinkHome.class);
    taskInfo.setNotificationSink(home,TaskNotificationInfo.ALL_EVENTS);
    
  3. Specify the event mask.
    The event mask is specified as an integer mask. You can either use an individual mask such as TaskNotificationInfo.CREATED to receive specific events, TaskNotificationInfo.ALL_EVENTS to receive all events or a combination of specific events.. For example:
    int eventMask = TaskNotificationInfo.CREATED+TaskNotificationInfo.PURGED;

Related tasks
Developing a task that calls a session bean
Developing a task that sends a JMS message
Managing tasks with a scheduler
Managing the scheduler service
Related reference
Scheduler interface



Searchable topic ID:   tsch_usenotificationsink
Last updated: Jun 21, 2007 8:07:48 PM CDT    WebSphere Business Integration Server Foundation, Version 5.0.2
http://publib.boulder.ibm.com/infocenter/wasinfo/index.jsp?topic=/com.ibm.wasee.doc/info/ee/scheduler/tasks/tsch_usenotificationsink.html

Library | Support | Terms of Use | Feedback