Invoking a jBPM 6 Process from Camel Spring

The Camel jbpm component provides integration with Business Process Management (BPM) Suit jBPM 6. Behind the hoods It uses kie-remote-client API to interact with jBPM instance over REST. Let’s see an example of it:

Say you have the following process available from the business central of jBPM:

camel jbpm 6 integration

The following sample blueprint shows how you can invoke the above process definition:

<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
    xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="          http://www.osgi.org/xmlns/blueprint/v1.0.0 https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd          http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd          http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0 http://aries.apache.org/schemas/blueprint-cm/blueprint-cm-1.1.0.xsd">
 
    <camelContext id="blueprint-bean-context" xmlns="http://camel.apache.org/schema/blueprint">
        <route id="jbpm-route">
            <from id="_from1" uri="timer://foo?fixedRate=true&amp;period=1000"/>
            <setHeader headerName="CamelJBPMProcessId" id="_setHeader1">
                <constant>project1.simpleprocess</constant>
            </setHeader>
            <to id="_to1" uri="jbpm:http://127.0.0.1:8080/business-central?userName=admin&amp;password=Password1!&amp;deploymentId=example:project1:1.0"/>
        </route>
    </camelContext>
</blueprint>

The above example uses the default operation, which is create new Process. Here is the list of available operations which you can pass via the operation parameter:

Process operations: startProcess, abortProcessInstance, signalEvent, getProcessInstance, getProcessInstances

Rule operations: fireAllRules, getFactCount, getGlobal, setGlobal

Work Item Operations: abortWorkItem, completeWorkItem

Task Operations: activateTask, addTask, claimNextAvailableTask, claimTask, completeTask, delegateTask, exitTask, failTask, getAttachment, getContent, getTasksAssignedAsBusinessAdministrator, getTasksAssignedAsPotentialOwnerByStatus, getTaskByWorkItem, getTaskBy, getTaskContent, getTasksByProcessInstance, getTasksByStatusByProcessInstance, getTasksOwned, nominateTask, releaseTask, resumeTask, skipTask, startTask, stopTask, suspendTask

Passing variables to the Process

Just as you would do with Java code, you can init a new jBPM process passing an HashMap of parameters:

<camelContext id="myContext"  xmlns="http://camel.apache.org/schema/blueprint">
    <route>
        <from uri="direct:start"/>
            <setHeader headerName="CamelJBPMProcessId">
                
                <constant ref="maps" />      
            </setHeader>
            
    </route>
</camelContext>

<property name="maps">
    <map>
        <entry key="Param 1" value="1" />
        <entry key="Param 2" value="2" />
    </map>
</property>

Do you want some more Spring stuff ? check Spring Boot Tutorials !