This is the 17th day of my participation in Gwen Challenge

Message start event

describe

The a message start event can be used to start a process instance with named information. This effectively allows us to use the message name to select the correct startup event from a set of alternative startup events.

When deploying one or more event process definitions that start with a message, note the following:

The name of the message launch event must be unique in a given process definition. Process definitions cannot have more than one message launch event with the same name. Activiti throws an exception when deploying the process definition that two or more message start events reference the same message if two or more message start events reference a message with the same message name.

The name of the message launch event must be unique in all deployed process definitions. Activiti throws an exception when deploying a process definition, causing one or more message launch events to reference a message with the same name as a message launch event that has been deployed by a different process definition.

Process versioning: Unsubscribe messages from previous versions when a new version of a process definition is deployed. The same is true for message events that do not exist in the new version.

When starting a process instance, the event RuntimeService can be triggered using the following method to start the message:

ProcessInstance startProcessInstanceByMessage(String messageName);
ProcessInstance startProcessInstanceByMessage(String messageName, Map<String, Object> processVariables);
ProcessInstance startProcessInstanceByMessage(String messageName, String businessKey, Map<String, Object< processVariables);
Copy the code

The messageName is the attribute messageEventDefinition in the given name messageRef by referring to the element messageRef. When starting a process instance, the following considerations apply:

Message start events are supported only on top-level processes. Embedded child processes do not support message start events.

If the process start events have multiple messages defined, then the runtimeService. StartProcessInstanceByMessage (…). Allows you to select the appropriate startup event.

If there are multiple message to start the process definition and a non start events, runtimeService. StartProcessInstanceByKey (…). And runtimeService. StartProcessInstanceById (…). Start a process instance with a non-start event.

If a process definition has multiple message start event, no not start events, runtimeService. StartProcessInstanceByKey (…). And runtimeService. StartProcessInstanceById (…). Throw an exception.

If a process definition has began a news event, runtimeService. StartProcessInstanceByKey (…). And runtimeService. StartProcessInstanceById (…). Start a new process instance with the event that the message starts.

If the process is started from a call activity, message start events are supported only in the following cases

In addition to the message start event, the process has a no-start event

The process has only one message start event and no other start events.

Graphic symbol

Message start events are displayed as circles with message event symbols. The symbol is not populated to visually capture (receive) the behavior.

XML representation

The XML representation of a message start event is a normal start event declaration with a messageEventDefinition child element:

<definitions id="definitions"
  xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
  xmlns:activiti="http://activiti.org/bpmn"
  targetNamespace="Examples"
  xmlns:tns="Examples">

  <message id="newInvoice" name="newInvoiceMessage" />

  <process id="invoiceProcess">

    <startEvent id="messageStart" >
    	<messageEventDefinition messageRef="tns:newInvoice" />
    </startEvent>
    ...
  </process>

</definitions>
Copy the code

Signal initiation event

describe

A signal start event can be used to start a process instance with a named signal. Can use the middle signal throw events or through the API (runtimeService. SignalEventReceivedXXX method) from the trigger signal from the process instance. In both cases, all process definitions with the same name signal start events are started.

Note that in both cases, you can also choose between synchronous and asynchronous startup of the process instance.

SignalName must be passed in the API as the attribute signalEventDefinition of the element signalRef referenced by the attribute signal of the given name name.

Graphic symbol signal start events are visualized as circles with signal event symbols. The symbol is not populated to visually capture (receive) the behavior.

XML representation

The XML representation of a signal start event is a normal start event declaration with a signalEventDefinition child element:

<signal id="theSignal" name="The Signal" />

<process id="processWithSignalStart1">
  <startEvent id="theStart">
    <signalEventDefinition id="theSignalEventDefinition" signalRef="theSignal"  />
  </startEvent>
  <sequenceFlow id="flow1" sourceRef="theStart" targetRef="theTask" />
  <userTask id="theTask" name="Task in process A" />
  <sequenceFlow id="flow2" sourceRef="theTask" targetRef="theEnd" />
	  <endEvent id="theEnd" />
</process>
Copy the code