How can we pass a processVariables to a camel route ?
See https://www.flowable.org/docs/userguide/index.html#bpmnCamelTask section following “The following table provides an overview of three available Camel behaviors”
Hi @PascalSchumacher, Thanks fro quick response.
My issue is inside the route builder class the body is coming as null.
Process Definition:
<?xml version="1.0" encoding="UTF-8"?> <definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:flowable="http://flowable.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.flowable.org/processdef"> <process id="SimpleCamelCallProcess" name="SimpleCamelCallProcess" isExecutable="true"> <startEvent id="startEvent1"></startEvent> <serviceTask id="simpleCall" name="smipleCall" flowable:type="camel"></serviceTask> <sequenceFlow id="sid-446FF04D-F525-4179-AB95-19F662EC9C21" sourceRef="startEvent1" targetRef="simpleCall"></sequenceFlow> <endEvent id="sid-6E2058CC-D118-4830-8934-429A70D36654"></endEvent> <sequenceFlow id="sid-7F543D13-8A7F-49EC-8181-5469BB38EF41" sourceRef="simpleCall" targetRef="sid-6E2058CC-D118-4830-8934-429A70D36654"></sequenceFlow> </process> <bpmndi:BPMNDiagram id="BPMNDiagram_SimpleCamelCallProcess"> <bpmndi:BPMNPlane bpmnElement="SimpleCamelCallProcess" id="BPMNPlane_SimpleCamelCallProcess"> <bpmndi:BPMNShape bpmnElement="startEvent1" id="BPMNShape_startEvent1"> <omgdc:Bounds height="30.0" width="30.0" x="60.0" y="145.0"></omgdc:Bounds> </bpmndi:BPMNShape> <bpmndi:BPMNShape bpmnElement="simpleCall" id="BPMNShape_simpleCall"> <omgdc:Bounds height="80.0" width="100.36219727999998" x="150.0" y="120.0"></omgdc:Bounds> </bpmndi:BPMNShape> <bpmndi:BPMNShape bpmnElement="sid-6E2058CC-D118-4830-8934-429A70D36654" id="BPMNShape_sid-6E2058CC-D118-4830-8934-429A70D36654"> <omgdc:Bounds height="28.0" width="28.0" x="295.36219728" y="146.0"></omgdc:Bounds> </bpmndi:BPMNShape> <bpmndi:BPMNEdge bpmnElement="sid-446FF04D-F525-4179-AB95-19F662EC9C21" id="BPMNEdge_sid-446FF04D-F525-4179-AB95-19F662EC9C21"> <omgdi:waypoint x="90.0" y="160.0"></omgdi:waypoint> <omgdi:waypoint x="150.0" y="160.0"></omgdi:waypoint> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge bpmnElement="sid-7F543D13-8A7F-49EC-8181-5469BB38EF41" id="BPMNEdge_sid-7F543D13-8A7F-49EC-8181-5469BB38EF41"> <omgdi:waypoint x="250.36219727999998" y="160.0"></omgdi:waypoint> <omgdi:waypoint x="295.36219728" y="160.0"></omgdi:waypoint> </bpmndi:BPMNEdge> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> </definitions>
Camel Route:
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
import org.springframework.stereotype.Component;
public class SimpleCamelCallRoute extends RouteBuilder {
@Override
public void configure() throws Exception {
from("flowable:SimpleCamelCallProcess:simpleCall?copyVariablesFromProperties=true").process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
System.out.println("Request Body: " + exchange.getIn().getBody());
}
}).to("direct:dm_prebureau_call");
}
}
When using copyVariablesFromProperties
you can access process variables in camel with exchange.getProperty("$PROCESS_VARIABLE_NAME")
.
If you like to have the process variables in the camel body you can use copyVariablesToBodyAsMap
.
@PascalSchumacher, Thank you .
copyVariablesToBodyAsMap has worked for me.