Information Technology Reference
In-Depth Information
return results;
}
As you can see, the
ExecutionResults
object has a
setData
method where we can
add specific output for our commands. The specific work item handler prepared to pass
tasks to the executor service, called
AsyncWorkItemHandler
, will take these para-
meters to match each result with a task output.
Overall, the
ExecutorService
object, the specific handlers, and the command it will
use can all be specified through a single line of code. This is clearly visible in the
Cus-
tomWorkItemHandlers.conf
file that can be found in the
kie-wb-edition
pro-
ject:
[
...
"DomainX" : new com.wordpress.marianbuenosayres.handlers.
DomainXWorkItemHandler(),
"DomainXAsync" : new org.jbpm.executor.impl.wih.
AsyncWorkItemHandler(
org.jbpm.executor.ExecutorServiceFactory.
newExecutorService(
javax.persistence.Persistence.
createEntityManagerFactory(
"org.jbpm.domain")
),
"com.wordpress.marianbuenosayres.handlers." +
"DomainXExecCommand"
)
]
The line for using the
AsyncWorkItemHandler
component looks a bit complicated,
but it does a lot in a single line. First, it creates a JPA persistence manager, then it creates
the executor service, and then it passes it to the
AsyncWorkItemHandler
component
along with the name of the
Command
class to execute its tasks.
The main advantage of using the executor service is that it provides the possibility of
handling many more concurrent calls that interact with process executions. Whenever we
invoke an interaction with a process instance (without the executor service strategy), we
will be hanging a thread until the automatic tasks involved in said process are finished or