Passing variables back and forth with a Java class

I saw one of the YouTube videos on how to connect Camunda to a Java class for twitter.

I tried to do that. However, I don’t know how can we pass parameters back and forth.

I am trying to get my hands dirty so trying a simple use-case for now, I need to authenticate a user, get usename/password and then have a JAVA program authenticate it and return success/deny.

I was able to create the class but I am clueless how to pass those variables. For most of your example programs where you are using a java class, there are no input/output parameters defined in the BPMN file.

I tried searching the documentation and examples but nothing definitive came out.

Please advise/point me in the right direction.

From the Java class I see the following code:
public class TweetContentDelegate implements JavaDelegate { <-- Is this mandatory? and where does JavaDelegate come from?

public void execute(DelegateExecution execution) throws Exception { <-- Is execute an internal function?
String content = (String) execution.getVariable(“content”); <-- The variable “content” I assume is from the BPMN workflow. How do we define them in the workflow itself to be passed to the class? Are all variables passed automatically?

How do we pass/return/modify a variable from the workflow?

Hi @TapanKhatri,

I think you should refer to following articles:


Thank you @aakhmerov

Just to the individuals who are looking for this like me:

This is what needs to be done:

In BPMN file:

  • Create a services task
  • In service task properties --> General --> Class --> enter your class name, you can browse as well
  • The variables in the flow will be automatically accessible, no additional settings are required

Java Code:
package org.camunda.bpm.yourPackage.yourClass;

import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.engine.delegate.JavaDelegate;

public class yourClassName implements JavaDelegate {

public void execute(DelegateExecution execution) throws Exception {
    String var1 = (String) execution.getVariable("bpmnVar1");
    String var2 = (String) execution.getVariable("bpmnVar2");
    String var3 = (String) execution.getVariable("bpmnVar3");

execution.setVariable("bpmnVar4", "bpmnVar4Value");
execution.setVariable("bpmnVar5", "bpmnVar5Value");