We can use the HTTP Connector in Camunda to call the relevant REST Endpoint from service tasks in the bpmn diagram. According to the below diagram, "Dummy Service 1 and 2" are service tasks which will invoke the Rest endpoints.
A generic API exists to set parameters of a request. The following parameters are available.
To avoid the exception, you have to use java serialization for persisting the long string value.
RuntimeService runtimeService = processEngine.getRuntimeService(); VariableMap variables = Variables.createVariables(); variables.putValueTyped("var", Variables .objectValue(aLongStringValue) // tells the engine to use java serialization for persisting the value .serializationDataFormat(SerializationDataFormats.JAVA) .create()); // Start a process instance ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testProcess", variables);
Limitations of this approach are:
- You cannot use this variable in queries, for example runtimeService.createVariableInstanceQuery().variableValueEquals("var", aLongStringValue).list() would not find the variable
- Whenever you fetch the variable, you will have to use the API that returns deserialized values (e.g. RuntimeService.getVariable("name") or RuntimeService.getVariableTyped("name", true)) to get the actual value. This can be a problem if you rely on the feature that the engine can serve variables in their serialized format (which is for a regular String variable just the plain String value; for a Java-serialized Object value, it is a base64-encoded String of the byte representation).
Ashen Jayasinghe
Software Developer
DMS