How to properly model an exclusive gateway

Hi,

I’m trying to figure out how an exclusive gateway can use an expression that checks a variable from a previous task.

In my understanding, I have to set
execution.setVariable("is_OK", true);

in my JavaDelegate CheckStuff, but this doesn’t work.
What am I missing?
I also tried with input- and output parameters, but this didn’t work either.

Regards
Matthias

diagram.bpmn (6.7 KB)

Hi Matthias,

I think you process can’t even be deployed since your service task has no implementation or type.

As first you have to define the implementation type, in your case a Java class.
So adjust your service task. Add an implementation and point to your JavaDelegate. You need to specify the package name and class name in the Java Class field. This should look in the xml similar to this: camunda:class="package.CheckStuff"

After that you need to remove the specified input/output mapping. You have no need to use the mapping, if you set the variable directly in the Java delegate. Your mapping overwrites the current is_OK variable with the null value. See the documentation for a more deeper explanation
Process Variables | docs.camunda.org
There you can also find the example and explanation, which says if you define no value the value will be null.

The content of an input/outputParameter specifies the value that is mapped to the corresponding variable. It can be a simple constant string or an expression. An empty body sets the variable to the value null.

<camunda:inputOutput>
   ...
  <camunda:inputParameter name="willBeNull"/>
  ...
</camunda:inputOutput>

Hope it helps.

Greets,
Chris

1 Like

Hi Chris,

thank’s a lot for your quick response.
I did not completely model the CheckStuff part in my process, I only wanted to illustrate the problem, as the real process is more complex.

Nevertheless, you were right. After removing the input/output mapping, it worked as expected.
So this looks like a typical RTFM case, right ? :wink:

Regards
Matthias

1 Like

Hi Matthias,

yeah we could summarize it like this :smiley:
But no worries, I also had to read the documentation.

Greets
Chris