Information Technology Reference
In-Depth Information
External interactions
As said before, good process engines are not meant to be monolithic software that manage
everything inside; instead, they are coordination frameworks for people and other systems.
One key component to achieve such a behavior is to provide a connector strategy to config-
ure and/or code external interactions between the process and other systems.
From the runtime point of view, each one of these external interaction instances are called
Work items. Work items are a representation of a specific step in a process execution. They
will store the input and output information for each interaction and its state (pending, act-
ive, completed, or aborted).
However, information about the actual occurrence of the external interaction invocation is
not enough. We need a way to create our own external interaction code to determine what
to do for each particular case. To handle these interactions, you need to implement the
WorkItemHandler interface, which is used to manage external interactions with other
systems by providing a way to invoke them from inside the process:
public interface WorkItemHandler {
public void executeWorkItem(WorkItem i, WorkItemManager m);
public void abortWorkItem(WorkItem I, WorkItemManager m);
}
We can later on bind different types of tasks to different WorkItemHandler implement-
ations by registering them in the KieSession exposed manager:
KieSession ksession =
KieServices.Factory.get().getKieClasspathContainer().newKieSession();
Ksession.getWorkItemManager().registerWorkItemHanlder("mySpecificTask",
new MySpecificWorkItemHandler());
Inside the executeWorkItem method, you can define the interaction with your external
system. You can continue with the execution after the method by calling the following
method:
m.completeWorkItem(i.getId(), i.getResults())
You can make the process stay in a continued state. This invocation is the one thing in
WorkItemHandler that will notify the engine that the step has been completed. If you
Search WWH ::




Custom Search