Why and when to perform this task
To receive notification events, call the setNotificationSink() method on the TaskInfo interface before creating the task. 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
com.ibm.websphere.scheduler.NotificationSinkHome com.ibm.websphere.scheduler.NotificationSink
The NotificationSink interface defines the following method:
public void handleEvent(TaskNotificationInfo task) throws java.rmi.RemoteException;
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);
# Use the NotificationSinkHome’s Global JNDI name # Assume that a TaskInfo was already created... $taskInfo setNotificationSink “ejb/MyNotificationSink”
int eventMask = TaskNotificationInfo.FIRED | TaskNotificationInfo.COMPLETE; taskInfo.setNotificationSink(home,eventMask);If you use JACL, your script might look like the following example:
# Set the event mask based on two event constants. set eventmask [expr [java::field com.ibm.websphere.scheduler.TaskNotificationInfo FIRED] + [java::field com.ibm.websphere.scheduler.TaskNotificationInfo COMPLETE]] # Set our Notification Sink based on our global JNDI name AND event mask. # Note: We need to use the full method signature here since the # method resolver can’t always detect the right method. $taskInfo {setNotificationSink String int} "ejb/MyNotificationSink" $eventmask
Result
A notification sink bean is now set on a TaskInfo object and can now be submitted to a scheduler using the create method.Related tasks
Developing a task that calls a session bean
Developing a task that sends a Java Message Service message
Managing tasks with a scheduler
Managing schedulers
Related reference
Scheduler interface