Standalone Modes - redhat-consulting/jbpm-ee GitHub Wiki

Collocated-Standalone Mode

jBPM-EE can also be collocated within the same Java EE Application Server, but not deployed with your application. This approach may be leveraged if there are several applications within the same server that need to share jBPM services, but are not able to be deployed together within the same Enterprise Archive (EAR). Because the jBPM-EE Service WAR is a separate deployable from your Custom Application, Local EJBs are not possible since the application reside within separate classloaders. Therefore, jBPM-EE leverages Remote @EJB 3.1.

height=400px|align=center

Details of the Approach

  • Because the jBPM-EE services are contained within the same server, there is no network-latency between the Custom Application and the jBPM Services.
  • 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 standalone mode allows the developers to easily inject the jBPM-EE services as Local EJBs by leveraging the @EJB and @Inject annotations.
    • Because these are remote EJBs, JNDI look-ups are required within the @EJB annotation.
@EJB(lookup = "java:global/jbpm-ee-services/AsyncCommandExecutorBean!org.jbpm.ee.services.ejb.remote.AsyncCommandExecutorRemote")
private AsyncCommandExecutorRemote asyncCommandExecutorService;
	
@EJB(lookup = "java:global/jbpm-ee-services/ProcessServiceBean!org.jbpm.ee.services.ejb.remote.ProcessServiceRemote")
private ProcessServiceRemote processService;
	
@EJB(lookup = "java:global/jbpm-ee-services/TaskServiceBean!org.jbpm.ee.services.ejb.remote.TaskServiceRemote")
private TaskServiceRemote taskService;

@EJB(lookup = "java:global/jbpm-ee-services/WorkItemServiceBean!org.jbpm.ee.services.ejb.remote.WorkItemServiceRemote")
private WorkItemServiceRemote workItemService;

@EJB(lookup = "java:global/jbpm-ee-services/WorkItemServiceBean!org.jbpm.ee.services.ejb.remote.WorkItemServiceRemote")
private WorkItemServiceRemote workItemService;

@EJB(lookup = "java:global/jbpm-ee-services/RuleServiceBean!org.jbpm.ee.services.ejb.remote.RuleServiceRemote")
private RuleServiceRemote ruleServiceRemote;

Note: Make sure to setup EJB Serialization Handling. See EJB Serialization Handling for more information.

Remote-Standalone Mode

jBPM-EE also supports remote execution between separate servers. Just like embedded and collocated, this model shares the same Java APIs! There are several communication protocols that can be used when leveraging this approach: REST, SOAP, or Remote EJB. This mode may be used when an application needs to scale it's tiers independently. Need to scale up jBPM? Deploy more JBoss EAP nodes with jBPM-EE services deployed. Need to scale the Custom Application? Add more JBoss EAP nodes to the Custom Application cluster.

height=350px|align=center

When should you leverage remote-standalone mode, and what are your trade offs with the different protocols?

  • Because the jBPM-EE services are deployed on a separate cluster than the Custom Application deployment, it allows independent scaling of the tiers. height=320px|align=center
  • Because SOAP and REST are supported, jBPM-EE can be integrated with other technologies outside of just Java.
  • SOAP and Rest do not support distributed transactions, while Remote EJBs do. Therefore, if you need your application to participate in the same transaction as the workflow you are interacting with, it is recommended to use the Remote EJB interface.
  • Calling the jBPM-EE services from Java, but still want to use REST or SOAP?
    • No problem! jBPM-EE provides Java clients that communicate over these protocols.
//REST
ProcessService processService = RestClientFactory.getProcessService(REST_URL);
TaskService taskService = RestClientFactory.getTaskService(REST_URL);
WorkItemService workItemService = RestClientFactory.getWorkItemService(REST_URL);
RuleService ruleService = RestClientFactory.getRuleService(REST_URL);

//SOAP
ProcessService processService = SoapClientFactory.getProcessService(PROCESS_SERVICE_URL);
TaskService taskService = SoapClientFactory.getTaskService(TASK_SERVICE_URL);
WorkItemService workItemService = SoapClientFactory.getWorkItemService(WORK_ITEM_SERVICE_URL);
RuleService ruleService = SoapClientFactory.getRuleService(RULE_SERVICE_URL);

###Create a Project with Remote 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 collocated and remote standalone modes. We accomplish this project templating by using Maven Archetypes. Read Maven Archetype

  • If you are running "collocated" or "remote", you will install the jBPM-EE services to your JBoss EAP instance as a WAR file.

    • jBPM-EE Services are already setup for Oracle, MySQL, DB2, Postgres, and MS SQL Server. Just edit the database configuration system property.
    • Create a project based on a the maven archetype jbpm-ee-remote-archetype, by typing
    mvn archetype:generate \
    -DgroupId=com.mycompany.app \
    -DartifactId=remoteApp \
    -DarchetypeArtifactId=jbpm-ee-remote-archetype \
    -DarchetypeGroupId=org.jbpm.jbpm-ee \
    

    or in JBoss Developer Studio/Eclipse, select File -> New -> Project... -> Maven Project and follow the screenshots

    height=400px|align=center

    height=400px|align=center

    height=400px|align=center

    height=400px|align=center

    height=400px|align=center

This will create a directory structure similar to remoteApp/ |____pom.xml |____remoteApp | |____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 | | | | | | | |____EJBRemoteTest.java | | | | | | | |____exception | | | | | | | | |____TestRuntimeException.java | | | | | | | |____RestTest.java | | | | | | | |____SoapTest.java

* Issue a **mvn clean install** on the application, this will create a war file called **remoteApp.war** in remoteApp/target
* Deploy the *.xml files in the resources to JBoss AS 7/EAP 6
* Deploy this application to JBoss AS 7/EAP 6

To begin, please install and configure a database. Read Databases