Get Variables in Camunda 8 - ZeebeWorker

Hi Team, I am new to Camunda 8. Here with the help of ZeebeWorker I am calling Service Task. I would like to Set & Get the process & local variables. I can able to set the variables. But not sure how to get the variables. Can anyone help me to get the variables in below code ?

@ZeebeWorker(type=“product”, autoComplete=true)
public Map<String, Object> getProduct(){
System.out.println(“Service Task Execution*”);
HashMap<String, Object> result = new HashMap();
result.put(“productId”, “100”);
return result;
}

Hello @vinothkumar ,

you can use the method parameters to get process variables:

Use the @Variables annotation on a parameter, the name of the parameter should be the process variable name.

I hope this helps

Jonathan

Hi @jonathan.lukas , Can you plz give me example ?

Hello @vinothkumar ,

there is an example in the github page of spring-zeebe:

The section is called @Variables or Handling @Variables

Jonathan

Thanks @jonathan.lukas .Its working fine. I just used @ZeebeVariable instead of @Variables.

Hello @vinothkumar ,

@ZeebeVariable is the old annotation which was deprecated in a newer library version. It works the same way.

Jonathan