This is an example of bpmn2 process implementation with Red Hat BPMS 6.4 showing the use of KIE Server (and it's Rest API), human tasks, tasks compensation, notification and task reassignment, time cycle and REST WIH (consuming two services that runs on WildFly Swarm).
Basically:
- Process for a new order approval
- Need for a human to approve or deny a request
- Parallel creation via REST of two permits (persisted data)
- Status check every 10s via REST
- If approved, process ends
- If denied, rollback of persisted data (in other application) occurs
Process image is at the end of this README.
If you need further details feel free to contact me.
- Red Hat BPM Suite 6.4
- Maven
- Java >7
- Fake SMTP (If you don't have any smtp server for a demo, this could fit)
- WS Permits
- Install and configure BPMS and Kie Server
- Clone this repo
- Create and start kie server container (Per Process Instance Runtime Strategy)
- Start WS Project and SMTP Server
- Test process using Kie Server REST API (Examples in topic 3)
- If you use the container name with the same name of the project GAV, (i.e.
com.kvarela:sv-process:1.0
) you will be able to see in Business Central, all the process instances and tasks created created by Kie Server.
-
Obs. Headers to use with POST and PUT (Auth required, you can use i.e.
bpms
user):Accept:application/json Content-Type:application/json
-
Start process:
POST http://localhost:8081/kie-server/services/rest/server/containers/com.kvarela:sv-process:1.0/processes/sv-process.newOrderPermitting/instances
{
"newOrder" :{
"com.kvarela.NewOrder": {
"address":"My Street Demo" ,
"hoaApproval": "",
"hoaMeetingDate": "2017-07-30",
"salesman": "salesman"
}
}
}
-
List available tasks for potential owner (user
salesman
) :PUT http://localhost:8081/kie-server/services/rest/server/queries/tasks/instances/pot-owners?user=salesman
-
Claim task 1 for user
salesman
PUT http://localhost:8081/kie-server/services/rest/server/containers/com.kvarela:sv-process:1.0/tasks/1/states/claimed?user=salesman
-
Start task 1 for user
salesman
PUT http://localhost:8081/kie-server/services/rest/server/containers/com.kvarela:sv-process:1.0/tasks/1/states/started?user=salesman
-
Complete task 1 for user
salesman
with aproval
PUT http://localhost:8081/kie-server/services/rest/server/containers/com.kvarela:sv-process:1.0/tasks/1/states/started?user=salesman
{
"outHoaApproval": "true"
}
- Add the Java Options in $JBOSS_HOME/bin/standalone.conf (Automatic marshaling for custom POJO and bypass user security)
JAVA_OPTS="$JAVA_OPTS -Dorg.kie.server.bypass.auth.user=true -Dorg.drools.server.filter.classes=true"
- Add the system properties (Configures BPMS & Kie Server)
<property name="org.kie.example" value="false"/>
<property name="org.drools.server.filter.classes" value="true"/>
<property name="org.jbpm.designer.perspective" value="full"/>
<property name="designerdataobjects" value="false"/>
<property name="org.kie.override.deploy.enabled" value="true"/>
<property name="org.kie.mail.session" value="java:jboss/mail/mail/jbpmMailSession"/>
<property name="org.kie.server.user" value="kieserver"/>
<property name="org.kie.server.pwd" value="redhat@123"/>
<property name="org.kie.server.location" value="http://localhost:8081/kie-server/services/rest/server"/>
<property name="org.kie.server.controller" value="http://localhost:8081/business-central/rest/controller"/>
<property name="org.kie.server.controller.user" value="kieserver"/>
<property name="org.kie.server.controller.pwd" value="redhat@123"/>
<property name="org.kie.server.id" value="decision-server"/>
- Configure the EAP SMTP Subsystem (For notification feature)
$ $JBOSS_HOME/jboss-cli.sh -c --controller=127.0.0.1:9990
[[email protected]:9990] /system-property=org.kie.mail.session:add(value="java:jboss/mail/
Default")
[[email protected]:9990] /subsystem=mail/mail-session=default:write-attribute(name=from, [email protected])
[[email protected]:9990] /subsystem=mail/mail-session=default/server=smtp:write-attribute(name=username,value=admin)
[[email protected]:9990] /subsystem=mail/mail-session=default/server=smtp:write-attribute(name=password,value=password)
[[email protected]:9990] /socket-binding-group=standard-sockets/remote-destination-outbound-socket-binding=mail-smtp:write-attribute(name=host,value=localhost)
[[email protected]:9990] /socket-binding-group=standard-sockets/remote-destination-outbound-socket-binding=mail-smtp:write-attribute(name=port,value=2525)
[[email protected]:9990] exit
- Add users to JBoss EAP (Will be used by BPMS)
$JBOSS_HOME/bin/add-user.sh -a -u kieserver -p redhat@123 -g kie-server,rest-all
$JBOSS_HOME/bin/add-user.sh -a -u salesman -p redhat@123 -g salesman=sales,kie-server,rest-all,rest-task,rest-query
$JBOSS_HOME/bin/add-user.sh -a -u executive -p redhat@123 -g executive=executives,user,kie-server,rest-task,rest-query,agent
$JBOSS_HOME/bin/add-user.sh -a -u Administrator -p redhat@123 -g executive=admin,rest-all,PowerUser,Administrators,kie-server
$JBOSS_HOME/bin/add-user.sh -a -u bpms -p redhat@123 -g admin,sales,executives,user,kie-server,rest-task,rest-query,agent
- Configure e-mail for these users. Add the lines below to
userinfo.properties
inside Business Central war. (By default, BPMS looks into this file).
$ vim $JBOSS_HOME/standalone/deployments/business-central.war/WEB-INF/classes/userinfo.properties
[email protected]:en-UK:admin
[email protected]:en-UK:salesman:[sales]
[email protected]:en-UK:executive:[executives]
[email protected]:en-UK:bpms:[executives,sales]
[email protected]:en-UK:Administrator:[executives,sales]
sales=:en-UK:sales:[salesman,bpms,Administrator]
executives=:en-UK:executives:[executive,bpms,Administrator]
Administrators=:en-UK:Administrators:[Administrator]
- Start BPM Suite EAP:
$JBOSS_HOME/bin/standalone.sh -Djboss.socket.binding.port-offset=1
-
Login in Business Central
-
User: bpms
-
Password: redhat@123
-
Via Business Central:
-
Create an organizational unit
-
Clone this repository
https://github.com/kmacedovarela/advanced-bpmn2-process.git
-
Access project authoring tab
-
Build and deploy project
sv-model
-
Build and deploy project
sv-process
- Access Tab
Deploy
, optionExecution Servers
- Click on
Add Container
- Select the project
sv-process
, and use the namecom.kvarela:sv-process:1.0
- Click
next
- Change the runtime strategy to
Per Process Instance
- Download and prepare WS Permits REST API
- Start the WS Permits REST API that will be consumed by the process instances. Inside the project folder, run:
mvn wildfly-swarm:run
- In case of Fake SMTP you can use
$ java -jar fake-smtp.jar