If an escalation occurs during the execution of a human task, you may want to notify an event handler within the application environment.
To configure an event and add it to your business application model, follow these instructions.
Declare a notification event handler for your task as described here:
- In the human task editor click the Details tab.
- In the Event handler name field, enter a name for your notification event handler. {This name is not the name of the implementation class.}
- Click Save.
Add your plugin to your application:
- Switch to the Resource perspective.
- In the Navigator, expand your business integration project.
- In the META-INF folder, create a new folder services.
- Right-click the services folder and select New > File .
- In the File name field of the New File wizard, , enter com.ibm.task.spi.EventHandlerNameNotificationEventHandlerPlugin Where EventHandlerName is the event handler name you have specified for your task.
- Click Finish.
- In the above file, write the fully qualified name of the event handler class.(For example : bpc.samples.plugin.EscalationNotificationPlugin)
Implementing the Event Handler Class:
EscalationNotificationPlugin.java
package bpc.samples.plugin;
import com.ibm.task.api.Escalation;
import com.ibm.task.api.TKIID;
import com.ibm.task.api.Task;
import com.ibm.task.spi.NotificationEventHandlerPlugin;
public class EscalationNotificationPlugin implements
NotificationEventHandlerPlugin {
public void escalationNotification(Task task, Escalation escalation) {
System.out.println("Entering method");
if(task != null && escalation != null)
{
System.out.println("Task template name: " + task.getTaskTemplateName());
System.out.println("Task name: " + task.getName());
System.out.println("Task state: " + task.getState());
System.out.println("Event handler name: " + task.getEventHandlerName());
System.out.println("Is escalated: " + task.isEscalated());
System.out.println("Escalation name: " + escalation.getName());
TKIID tkId = task.getID();
System.out.println("Task Id : " + tkId);
}
}
}
- Switch to the Business Integration perspective and open your task in the human task editor.
- In the Escalation settings section, select the escalation.
- Click the Details tab.
- Configure the escalation as needed. For Notification type, choose Event from the list of available options.
- Save your work.
Hi Harish,
ReplyDeleteThanks for the publish. Can you please help us in configuring EventHandler for all the tasks of a process. We have many processes running and needed a common place to intercept task status change event.