# Query on Variables while Publishing Message

**URL:** <https://forum.camunda.io/t/query-on-variables-while-publishing-message/48051>\
**Category:** Discussion & Questions\
**Tags:** process-engine\
**Created:** [October 10, 2023, 7:08am UTC](https://forum.camunda.io/t/query-on-variables-while-publishing-message/48051 "2023-10-10T07:08:20Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![camundabpmlearner](https://forum.camunda.io/letter_avatar_proxy/v4/letter/c/3be4f8/32.png) [@camundabpmlearner](https://forum.camunda.io/u/camundabpmlearner)\
**Post date:** [October 10, 2023, 7:08am UTC](https://forum.camunda.io/t/query-on-variables-while-publishing-message/48051/1 "2023-10-10T07:08:21Z")

</div>

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.

 ![image](https://forum.camunda.io/uploads/default/original/3X/b/8/b876e0cb31d0caaf41c8c185ce0ea1efa7f8d7f0.png)

---

<div class="post-metadata">

**Author:** ![Praveen\_Kumar\_Reddy](https://forum.camunda.io/user_avatar/forum.camunda.io/praveen_kumar_reddy/32/25741_2.png) [@Praveen\_Kumar\_Reddy](https://forum.camunda.io/u/Praveen_Kumar_Reddy)\
**Post date:** [October 10, 2023, 7:16am UTC](https://forum.camunda.io/t/query-on-variables-while-publishing-message/48051/2 "2023-10-10T07:16:54Z")

</div>

Hi @camundabpmlearner ,

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

```auto
		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);
				});

```

---

<div class="post-metadata">

**Author:** ![camundabpmlearner](https://forum.camunda.io/letter_avatar_proxy/v4/letter/c/3be4f8/32.png) [@camundabpmlearner](https://forum.camunda.io/u/camundabpmlearner)\
**Post date:** [October 10, 2023, 7:18am UTC](https://forum.camunda.io/t/query-on-variables-while-publishing-message/48051/3 "2023-10-10T07:18:47Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Praveen\_Kumar\_Reddy](https://forum.camunda.io/user_avatar/forum.camunda.io/praveen_kumar_reddy/32/25741_2.png) [@Praveen\_Kumar\_Reddy](https://forum.camunda.io/u/Praveen_Kumar_Reddy)\
**Post date:** [October 10, 2023, 7:32am UTC](https://forum.camunda.io/t/query-on-variables-while-publishing-message/48051/4 "2023-10-10T07:32:39Z")

</div>

Unfortunately I’m not very experienced in Go lang

Went through go client [documentation](https://docs.camunda.io/docs/apis-tools/go-client/go-get-started/?modeler=web#create-a-process-instance)

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

 ![image](https://forum.camunda.io/uploads/default/original/3X/e/8/e8565fcd8ee4e0d614b6f3c1ef1d79047b5961c4.png)

---

<div class="post-metadata">

**Author:** ![camundabpmlearner](https://forum.camunda.io/letter_avatar_proxy/v4/letter/c/3be4f8/32.png) [@camundabpmlearner](https://forum.camunda.io/u/camundabpmlearner)\
**Post date:** [October 10, 2023, 7:43am UTC](https://forum.camunda.io/t/query-on-variables-while-publishing-message/48051/5 "2023-10-10T07:43:56Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Praveen\_Kumar\_Reddy](https://forum.camunda.io/user_avatar/forum.camunda.io/praveen_kumar_reddy/32/25741_2.png) [@Praveen\_Kumar\_Reddy](https://forum.camunda.io/u/Praveen_Kumar_Reddy)\
**Post date:** [October 10, 2023, 8:43am UTC](https://forum.camunda.io/t/query-on-variables-while-publishing-message/48051/6 "2023-10-10T08:43:22Z")

</div>

Hi @camundabpmlearner ,

Hope my answers are helpful

1. That is a screenshot directly from documentation from [here](https://docs.camunda.io/docs/apis-tools/go-client/go-get-started/?modeler=web#work-on-a-task)  
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
