7.19. Passing Parameters to a jBPM5 Process on signalEvent

download PDF
// create the ESB message
Message esbMessage = MessageFactory.getInstance().getMessage();
// set the process event type as defined in the process definition
esbMessage.getProperties().setProperty("processEventType", "NewMessage");
// add a parameter
esbMessage.getProperties().setProperty("name", "Hardy");

// setup data required to identify the intended target process instance
ContextImpl ctxi = (ContextImpl) esbMessage.getContext();
// set the session id
ctxi.setContext("jbpm5-session-id", sessionId);
// set the instance id.
ctxi.setContext("jbpm5-processinstance-id", processInstanceId);
The following 'name' property will be assigned on process start when the 'name' ESB message property will be set:
<definition ...>
 
    <itemDefinition id="_nameItem" structureRef="String" />
 
    <process name="Hello" tns:packageName="defaultPackage" ...>
        <property id="name" itemSubjectRef="_nameItem"/>
        <!-- ... -->
    </process>
    <!-- ... -->
</definition>
To define a process property of type java.util.Map:
<definition ...>

  <itemDefinition id="_objectMapItem" structureRef="java.util.Map" />

  <process name="Hello" tns:packageName="defaultPackage" ...>

    <property id="objectMap" itemSubjectRef="_objectMapItem"/>
    <!-- ... -->
  </process>
  <!-- ... -->
</definition>
To extract parameters:
String name2 = objectMap.get("name"); // will retrieve the Hardy string
Red Hat logoGithubRedditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

© 2024 Red Hat, Inc.