Embedded Mode - redhat-consulting/jbpm-ee GitHub Wiki
jBPM-EE can be embedded with your application as a single deployable by leveraging Enterprise Archives (EAR) format. When leveraging this approach, your application can take advantage of @EJB
and @Inject
annotations to integrate the jBPM services into your application!
Details of the Approach
- Because the jBPM-EE services are contained within the same deployable as your application, this approach does not require Java serialization, which makes it the fastest approach.
- The jBPM-EE services all leverage
@Required
EJB Transaction annotations.- This ensures that the jBPM-EE services are executed within a transaction.
- As long as your application starts and leverages JTA transactions, the jBPM-EE Services will coordinate their transactions with your existing JTA transaction.
- Leveraging embedded mode allows the developers to easily inject the jBPM-EE services as Local EJBs by leveraging the
@EJB
and@Inject
annotations.- Because these are local EJBs, no JNDI location is required. Just inject and enjoy!
@EJB
private AsyncCommandExecutorLocal asyncCommandExecutorService;
@EJB
private ProcessServiceLocal processService;
@EJB
private TaskServiceLocal taskService;
@EJB
private WorkItemServiceLocal workItemService;
@EJB
private RuleServiceLocal ruleService;
###Creating an Application with the Embedded Maven Archetype The following section guides you through creating a custom project that provides the default structure and dependencies for creating a new application that conforms to the embedded mode. We accomplish this project templating by using Maven Archetypes. Read Maven Archetype
To begin, please install and configure a database.
-
Read Databases
-
Create a project based on a the maven archetype jbpm-ee-embedded-archetype, by typing
mvn archetype:generate \ -DgroupId=com.mycompany.app \ -DartifactId=embeddedApp \ -DarchetypeArtifactId=jbpm-ee-embedded-archetype \ -DarchetypeGroupId=org.jbpm.jbpm-ee \ -DdbType=mysql
or in JBoss Developer Studio/Eclipse, select File -> New -> Project... -> Maven Project and follow the screen-shots
Please check the "Include snapshot archetypes" check-box, then filter on jbpm-ee-embedded-archetype
-
Please change the groupId and artifactId parameters to your desired name
-
Please note that if the dbType parameter is not provided, its value defaults to mysql, other possible values for designating your database's vendor are oracle, db2, and sqlserver at this time.
-
This will create a directory structure similar to
or
embeddedApp/ |____embeddedApp | |____pom.xml | |____resources | | |____jbpm-ee-ds.xml | | |____jbpm-ee-jms.xml | | |____jbpm-ee-timer-ds.xml | |____src | | |____main | | | |____java | | | | |____com | | | | | |____mycompany | | | | | | |____app | | | | | | | |____BaseEJBTest.java | | | | | | | |____BaseTest.java | | | | | | | |____EJBLocalTest.java | | | | | | | |____exception | | | | | | | | |____TestRuntimeException.java |____embeddedApp-ear | |____pom.xml |____pom.xml
- Issue a mvn clean install on the application, this will create an ear file called embeddedApp.ear in embeddedApp-ear/target.
- Deploy the *.xml files in the resources to JBoss AS 7/EAP 6
- Deploy this application to JBoss AS 7/EAP 6
-