7.19. signalEvent で jBPM5 プロセスへパラメーターを渡す
// 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);
name のメッセージプロパティーが設定されている場合、プロセスの開始時に以下の name プロパティーが割り当てられます。
<definition ...>
<itemDefinition id="_nameItem" structureRef="String" />
<process name="Hello" tns:packageName="defaultPackage" ...>
<property id="name" itemSubjectRef="_nameItem"/>
<!-- ... -->
</process>
<!-- ... -->
</definition>
java.util.Map タイプのプロセスプロパティーを定義するには、以下を実行します。
<definition ...>
<itemDefinition id="_objectMapItem" structureRef="java.util.Map" />
<process name="Hello" tns:packageName="defaultPackage" ...>
<property id="objectMap" itemSubjectRef="_objectMapItem"/>
<!-- ... -->
</process>
<!-- ... -->
</definition>
パラメーターを抽出するには、以下を実行します。
String name2 = objectMap.get("name"); // will retrieve the Hardy string