Activiti workflow learning ----- Based on version 5.19.0 (8) and activiti5.19.0

Source: Internet
Author: User

Activiti workflow learning ----- Based on version 5.19.0 (8) and activiti5.19.0
8.1.5 Start Event

Continue to share the notes of the previous Event. Start Event indicates that the process starts. As for the type of the Start Event (when the message arrives, the specified Event loop starts ), defines how to start with a small icon in the Start event circle icon, which is reflected in xml as different child elements.

Start Event is always captured: Wait for the trigger to trigger at any time.

The following shows the xml of start event. initiator refers to the process initiator. After the process starts, it will be saved:

<startEvent id="request" activiti:initiator="xxx" />

The user "xxx" can implement the same function in the Code:

1 try {2   identityService.setAuthenticatedUserId("bono");3   runtimeService.startProcessInstanceByKey("someProcessKey");4 } finally {5   identityService.setAuthenticatedUserId(null);6 }

Use the IdentityService. setAuthenticatedUserId (String) method in try-catch.

8.1.6 None Start Event

None start event indicates that no trigger is defined in the process definition. This means that the process engine does not automatically start the process instance. developers need to call the API to implement it (generally the sub-process is like this ):

1 ProcessInstance processInstance = runtimeService.startProcessInstanceByXXX();

The appearance of a none-start event in the activiti visualization plug-in:

In bpmn files

<startEvent id="start" name="my start event" />

ConfigurableFormKey attributes:

<startEvent id="request" activiti:formKey="org/activiti/examples/taskforms/request.form" />
8.1.7 Timer Start Event

Timer start event is used to start a process instance at a specified time. It is mainly used when the process only needs to be started once or the process starts cyclically. Note: The sub-process cannot have a timer start event. Generally, the process is started after the process is released. At this time, there is no need to call the startProcessInstanceByXXX method. Although the call is unlimited, multiple process instances run at the same time. At the same time, if a new version is released in the process, the timer start event will only start the process definition of the latest version.

What the activiti visualization plug-in looks like:

In the xml format of pbmn files:

<startEvent id="theStart">  <timerEventDefinition>    <timeCycle>R4/2011-03-11T12:13/PT5M</timeCycle></timerEventDefinition></startEvent>

Or specify the event to start:

<startEvent id="theStart">  <timerEventDefinition>    <timeDate>2011-03-11T12:13:14</timeDate>  </timerEventDefinition></startEvent>
8.1.7 Message Start Event

A Message Start Event uses the named Message start process instance. When there are many start events, you can select the correct Start event to start the process instance using the Message name.

When defining one or more release processes, pay attention to the following issues:

The name of each message start event must be unique in the process definition. In the process definition, it is not necessary to make the names of multiple message start events the same. When messages referenced by multiple message start events are the same, the workflow throws an exception.

After the process version is upgraded, the previous message start event will be replaced by the new message start event.

Call the RunTimeService API:

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

MessageName is the value referenced by messageRef in messageEventDefinition in the message node. Message start event only supports top-level processes, but does not support subprocesses. Call runtimeService. startProcessInstanceByMessage (...) Message event can be selected. For how to use runtimeService. startProcessInstanceByKey (...) And runtimeService. startProcessInstanceById (...) None start event is used. If multiple message events are defined at this time, an exception is thrown.

For example, in the messageEventDefinition node, configure:

<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>
8.1.8 Signal Start Event

Start a process instance with a named signal. The signal throws or calls an API (runtimeService) in the process. triggered by the signalEventReceivedXXX method). If all process definitions have signal events of the same name, they will be started. In both cases, you can start the process instance synchronously or asynchronously.

The parameter signalName that calls the API comes from the signalRef configuration of the signalEventDefinition node in the process definition, while signalRef comes from the signal attribute name. The visual symbol of signal start event is as follows:

Parse to xml:

 1 <signal id="theSignal" name="The Signal" /> 2  3 <process id="processWithSignalStart1"> 4   <startEvent id="theStart"> 5     <signalEventDefinition id="theSignalEventDefinition" signalRef="theSignal"  /> 6   </startEvent> 7   <sequenceFlow id="flow1" sourceRef="theStart" targetRef="theTask" /> 8   <userTask id="theTask" name="Task in process A" /> 9   <sequenceFlow id="flow2" sourceRef="theTask" targetRef="theEnd" />10       <endEvent id="theEnd" />11 </process>
8.1.9 Error Start Event

An error start event is often used in subflows and cannot be used to start a process instance. The error start event is an interruption event. The visual symbols of the error start event are as follows:

Resolved to xml:

1 <startEvent id="messageStart" >2     <errorEventDefinition errorRef="someError" />3 </startEvent>

An end event is often used in the process and sub-process, and the end event always throws information, which means that results will be thrown when the process is executed until the end event.

8.2.1 None End Event

An empty end event means that no result is thrown, so the process engine does not execute any additional tasks under the current execution path. The visualization of a none end event.

<endEvent id="end" name="my end event" />
8.2.2 Error End Event

If the process runs to the error end event, the current path execution will end early and an error will be thrown. This error will be captured by the matching boundary event. If the corresponding boundary event is not found, an exception will be thrown, as shown in the following figure:

Xml parsing:

<endEvent id="myErrorEndEvent">  <errorEventDefinition errorRef="myError" /></endEvent>

The myError referenced by errorRef is configured in error:

<error id="myError" errorCode="123" />...<process id="myProcess">...

The errorErrorCodeThe boundary event will be matched. If errorRef does not find an error, errorRef will be used as the short name of errorCode, which is unique in Activiti, for example:

<error id="myError" errorCode="error123" />...<process id="myProcess">...  <endEvent id="myErrorEndEvent">    <errorEventDefinition errorRef="myError" />  </endEvent>...

It is equivalent:

<endEvent id="myErrorEndEvent">  <errorEventDefinition errorRef="error123" /></endEvent>
8.2.3 Terminate End Event

When the process is executed to the terminate end event, both the current process and the sub-process will end. In terms of concept, when the execution ends, the process instance and sub-process will end. In BPMN2.0, A sub-flow can be embedded into sub-flows with transactions, which is applicable to general situations. For example, if there are multiple instance call activities or embedded sub-flows, only this instance will end, and other instances and process instances will not be affected. The visual effects of the design in the process designer are as follows:

If it is parsed as xml:

<endEvent id="myEndEvent >  <terminateEventDefinition activiti:terminateAll="true"></terminateEventDefinition></endEvent>

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.