Show Table of Contents
16.3. EJB Interface
Starting with version 6.1, the BPM Suite execution engine supports an EJB interface for accessing
KieSession and TaskService remotely. This allows for close transaction integration between the execution engine and remote customer applications.
The implementation of this interface is a single, framework independent and container agnostic API that can be used with framework specific code. The services are exposed using the jbpm.services.api and the org.jbpm.services.ejb package and described in the next section. There is also support for CDI via the org.jbpm.services.cdi package.
The implementation doesn't support a
RuleService at this time, but the ProcessService class exposes an execute method that allows you to use various rule related commands, like InsertCommand and FireAllRulesCommand.
Deployment of EJB Client
The EJB interface is currently only supported on Red Hat JBoss EAP. An implementation client in the form of a WAR file is available and can be extracted from the Maven Repository for Red Hat JBoss BPM Suite from the customer portal. This EJB client is present in the Maven Repository in the form of a JAR file:
jbpm-services-ejb-client-VERSION-redhat-MINOR.jar.
Note that the inclusion of EJB doesn't mean that CDI based services will be replaced. CDI And EJB can be used together but this is not recommended. Since EJB's are not available by default in Business Central, the package kie-services must always be present in the classpath. The EJB services are suitable for embedded use cases.
16.3.1. EJB Interface Methods
There are 5 main service interfaces that can be used by remote EJB clients. These methods are present in the following packages:
- org.jbpm.services.ejb.api: the extension to the Services API for EJB needs.
- org.jbpm.services.ejb.impl: EJB wrappers on top of the core service implementation.
- org.jbpm.services.ejb.client: The EJB remote client implementation that works on JBoss EAP only.
DefinitionService: Use this interface to gather information about processes (id, name and version), process variables (name and type), defined reusable subprocesses, domain specific service and user tasks and user task input and outputs.DeploymentService: Use this interface to initiate deployments and un-deployments. Methods includedeploy,undeploy,getRuntimeManager,getDeployedUnits,isDeployed,activate,deactivateandgetDeployedUnit. Calling thedeploymethod with an instance ofDeploymentUnitdeploys it into the runtime engine by buildingRuntimeManagerinstance for the deployed unit. Upon successful deployment an instance ofDeployedUnitinstance is created and cached for further usage.These methods only work if the artifact/project is already installed in a Maven repository.ProcessService: Use this interface to control the lifecycle of one or more Processes and Work Items.RuntimeDataService: Use this interface to retrieve data about the runtime: process instances, process definitions, node instance information and variable information. It includes several convenience methods for gathering task information based on owner, status and time.UserTaskService: Use this interface to control the lifecycle of a user task. Methods include all the usual ones:activate,start,stop,executeamongst others.
A synchronization service that syncs information between Business Central and the EJBs is also available. The synchronization interval can be set with the org.jbpm.deploy.sync.int system property.
Note
You must wait for the synchronization service to finish its synchronization of information before trrying to access this updated information via REST. Until this synchronization is finished the EJBs will not see changes done via REST.
16.3.2. Generating the EJB Services WAR
This example shows you how to create an EJB Services WAR using the new EJB Interface.
- Update the
persistence.xmlfile in Business Central. Edit the property hibernate.hbm2ddl.auto and set its value toupdate(instead ofcreate). - Register the Human Task CallBack using a startup class:
@Singleton @Startup public class StartupBean { @PostConstruct public void init() { System.setProperty("org.jbpm.ht.callback", "jaas"); } } - Generate the WAR file:
mvn assembly:assembly - Deploy the generated war file (
sample-war-ejb-app.war) in the JBoss EAP instance that JBoss BPM Suite 6.1 is running in.Note
If deploying on a JBoss EAP container separate from the one where JBoss BPM Suite is running, you need to:- You need to configure your application/app server to invoke a remote EJB.
- You need to configure your application/app server to propagate the security context.
Warning
When you deploy your EJB WAR on the same instance of JBoss EAP, avoid using theSingletonstrategy for your runtime sessions. If you use theSingletonstrategy, both applications will load the sameksessioninstance from the underlying file system and cause optimistic lock exceptions. - To test, create a simple web application and inject the EJB Services:
@EJB(lookup = "ejb:/sample-war-ejb-app/ProcessServiceEJBImpl!org.jbpm.services.ejb.api.ProcessServiceEJBRemote") private ProcessServiceEJBRemote processService; @EJB(lookup = "ejb:/sample-war-ejb-app/UserTaskServiceEJBImpl!org.jbpm.services.ejb.api.UserTaskServiceEJBRemote") private UserTaskServiceEJBRemote userTaskService; @EJB(lookup = "ejb:/sample-war-ejb-app/RuntimeDataServiceEJBImpl!org.jbpm.services.ejb.api.RuntimeDataServiceEJBRemote") private RuntimeDataServiceEJBRemote runtimeDataService;

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.