Pass variables to between different processes

How to achieve below

Below is my requirement:

  1. Process 1 runs in current thread .Process 2 ,Process 3 …runs in another same thread(in background)
    2)My questin is how to pass variables from Process 2 to Process 3,4,5…

This is how i am passing the variables from Process 1 to Process 2 .And it works.How to pass variable of Process2 to Process 3

@Component
public class MessageEndEvent implements JavaDelegate{
	
	

	@Override
	public void execute(DelegateExecution execution) throws Exception {
		
		System.out.println(" In MessageEndEvent ");
		// TODO Auto-generated method stub
					execution.
				getProcessEngine().
				getRuntimeService().
				createMessageCorrelation("my-message")
				 .processInstanceBusinessKey("poc-workflow")
				 .setVariable("payment_type", "creditCard")
				  .correlate();

Why use a Service-Task to start Process3?
Wouldn’t it be clearer (both from a documentation and code perspective) to simply use the “Call Activity” and map the variables in the Call Activity function?

Call Activity is a core-function in BPMN, so all Engines should support it (Camunda DOES)

@GotnOGuts gow to use call activity .can u provide an example?

Select the “Step 3” activity
Click the Wrench icon
Select “Call Activity”
In the details pane, enter the Process Identifier of Process 3 and select “Latest” for version.
In the details pane, select the variables to map

How to use in Java code?I am using SPring Boot.i am able to call sub process but not able to pass variables(data)

“Call Activity” isn’t something you do in Java code, it’s something you do in the BPMN model itself.

2 Likes

Hi @my_camunda_profie_1 ,

I agree with @GotnOGuts , chaining processes could be modeled using call activities, with the advantage of being much clearer to any reader of your models.

I could imagine a main process like:

camunda_forum_42266.bpmn (5.3 KB)

On advancing this process, Camunda will call subprocesses as necessary. All variables of the parent scope will then be transferred to the call activity if no specific inputs are defined on the call activity. If you need to set or compute additional parameters for your subprocess, you could do so using e. g. a script task.

I hope this helps,
Adagatiya

1 Like