bpmn - Query process instances based on starting message name -
env: camunda 7.4, bpmn 2.0
given process, can started multiple start message events.
- is possible query process instances started specific messages identified message name?
- if yes, how?
- if no, why?
- if not @ moment, when?
some apis incidentmessages?
that no out-of-the-box feature should easy build using process variables.
the basic steps are:
1. implement execution listener sets message name variable:
public class messagestarteventlistener implements executionlistener { public void notify(delegateexecution execution) throws exception { execution.setvariable("startmessage", "messagename"); } }
note via delegateexecution#getbpmnmodelelementinstance
can access bpmn element listener attached to, determine message name dynamically.
2. declare execution listener @ message start events:
<process id="executionlistenersprocess"> <startevent id="thestart"> <extensionelements> <camunda:executionlistener event="start" class="org.camunda.bpm.examples.bpmn.executionlistener.messagestarteventlistener" /> </extensionelements> <messageeventdefinition ... /> </startevent> ... </process>
note bpmn parse listener, can add such listener programmatically every message start event in every process definition. see this example.
3. make process instance query filtering variable
runtimeservice runtimeservice = processengine.getruntimeservice(); list<processinstance> matchinginstances = runtimeservice .createprocessinstancequery() .variablevalueequals("startmessage", "messagename") .list();
Comments
Post a Comment