Query on Variables while Publishing Message

Hi,
In Zeebe while triggering message, along with correlation key, there is an option to pass variable (attached screenshot). Though call is successful, I don’t see those variables in process scope or other scope. So, I’m not getting how to pass them or what is the purpose of these methods.

Can you please provide your input.

Thank you in advance.

Hi @camundabpmlearner ,

For sending the variables into the process during message publish you can try adding them similar to this

		final Map<String, Object> variables = new HashMap<String, Object>();
		
		variables.put("name", "John");
		variables.put("age", Integer.valueOf("22"));

		client.newPublishMessageCommand().messageName("Message-Received").correlationKey("key").variables(variables)
				.send().exceptionally(throwable -> {
					throw new RuntimeException("Could not publish message", throwable);
				});

I did same… but in go lang client… I dont see them in process scope

Unfortunately I’m not very experienced in Go lang

Went through go client documentation

I’m unsure whether it will work, You could try sending the variables from .VariablesFromMap(variables)

1 Like

I have few questions:

  1. Here(screenshot you shared) totalPrice is new variable or existing variable?
  2. In your sample java code you are passing name and age… how is get mapped to process?
  3. Do we need to map these variable names in output section of message event?
  4. When it is mapped, what is the scope level of these variables?

Hi @camundabpmlearner ,

Hope my answers are helpful

  1. That is a screenshot directly from documentation from here
    I think it is an existing variable, For your case you need to create a map and assign variables to it

  2. It will be a key, value pair and taken as variable name and value in process , The zeebe client will send them to the respective process instance which is triggered after matching global message reference

  3. No need to map in output section they will be sent directly to process

  4. you can access them anywhere in process

1 Like