Activiti Workflow Learning-----Based on 5.19.0 version (8)

Source: Internet
Author: User

8.1.5 Start Event

To continue the shared note on an event, start event indicates that it is the beginning of the process, as to the type of the start events (the message arrives at the beginning, the specified event loop starts, etc.), and the definition starts with a small icon representation in the Start Event Circle icon, which is reflected in the XML as a child element.

The Start event is always captured: wait for the trigger to trigger at any time.

The XML for Start event is shown below, where initiator refers to the process initiator, which is saved after the process begins:

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

and the user "xxx" in the code to achieve the same functionality can:

 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

A none start event says that there are no triggers defined in the process definition. means that the process engine does not automatically start the process instance and requires the developer to invoke the API implementation (which is what a typical subprocess would look like):

1 processinstance processinstance = runtimeservice.startprocessinstancebyxxx ();

A none start event looks like in the Activiti visual plug-in:

In the BPMN file, it is

<id= "Start"  name= "My Start event"/>

You can configure the Formkey property:

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

The Timer Start Event function starts the process instance at a specified time. It is mainly used in the process only need to start once or process cycle start. Note: The sub-process is not able to have a timer start event. Typically, the process is started after the process has been released, and there is no need to call the Startprocessinstancebyxxx method, although the call is unrestricted, but causes multiple process instances to run at the same time. At the same time, if a new version of the process is released, the timer start event will only start the latest version of the process definition.

What to look like in the Activiti visual plug-in:

In the XML format of the Pbmn file:

<id= "TheStart">  <timereventdefinition >    < timecycle > r4/2011-03-11t12:13/pt5m</timecycle></  Timereventdefinition></startevent>

or specify event initiation:

<id= "TheStart">  <timereventdefinition >    < timedate >2011-03-11t12:13:14</timedate>  </ timereventdefinition > </ startevent >
8.1.7 Message Start Event

A message start event starts the process instance with a named message and, when there are many start event names, you can select the correct start event to start the process instance.

There are several issues to be aware of when publishing process definitions are one or more:

The name of each message start event is unique within the process definition, and it is not necessary in the process definition to make multiple message start event names the same. When multiple message start event references are the same, the workflow throws an exception.

After the upgrade process version, the previous message start event will be replaced by the new version of 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);

Where MessageName is the value of name in the Messageref Reference message node in Messageeventdefinition. The message start event supports only the top-level process and does not support sub-processes. Call Runtimeservice.startprocessinstancebymessage (....) You can select the message event. For use with Method Runtimeservice.startprocessinstancebykey (....) and Runtimeservice.startprocessinstancebyid (...?) The None start event is used, and if more than one message event is defined at this time, an exception is thrown.

For example, configure in the Messageeventdefinition node:

<DefinitionsID= "Definitions"xmlns= "Http://www.omg.org/spec/BPMN/20100524/MODEL"Xmlns:activiti= "HTTP://ACTIVITI.ORG/BPMN"targetnamespace= "Examples"Xmlns:tns= "Examples">  <messageID= "Newinvoice"name= "Newinvoicemessage" />  <ProcessID= "Invoiceprocess">    <starteventID= "Messagestart" >        <messageeventdefinitionMessageref= "Tns:newinvoice" />    </startevent>    ...  </Process></Definitions>
8.1.8 Signal Start Event

Using a named signal to start a process instance, the signal is thrown in the middle of the process or invoked by the API (Runtimeservice.signaleventreceivedxxx method), and all the process definitions are initiated if the signal event has the same name. In either case, you can choose to start the process instance synchronously or asynchronously.

The parameters of the calling API Signalname from the SIGNALREF configuration of the Signaleventdefinition node in the process definition, and signalref from the signal property name. The visual symbol for the signal start event is shown:

Parse to XML:

1 <SignalID= "Thesignal"name= "The Signal" />2 3 <ProcessID= "ProcessWithSignalStart1">4   <starteventID= "TheStart">5     <signaleventdefinitionID= "Thesignaleventdefinition"Signalref= "Thesignal"  />6   </startevent>7   <SequenceflowID= "Flow1"Sourceref= "TheStart"Targetref= "Thetask" />8   <UsertaskID= "Thetask"name= "Task in process A" />9   <SequenceflowID= "Flow2"Sourceref= "Thetask"Targetref= "TheEND" />Ten       <endeventID= "TheEND" /> One </Process>
8.1.9 Error Start Event

An error start event is commonly used in sub-processes, and it cannot be used to start a process instance. An error start event is an interrupt event. The visual symbol for the error start event is shown:

Parse to XML as:

1 <  ID= "Messagestart">2     <errorref  = "Someerror"/>3</startevent>

An end event is often used in processes and sub-processes, and the end event always throws out information, meaning that the process executes to the end of the event with results thrown.

8.2.1 None End Event

An empty end event means that no specified result is thrown, so the process engine does not perform any additional things under the current execution path. The visual effect of a none end event.

<id= "End"  name= "My End Event"/>
8.2.2 Error End Event

If the process executes to the error end event, the current path execution will end prematurely and throw an error that will be caught by the matching boundary event, and if no corresponding boundary event is found, an exception will be thrown, as shown in his specific visualization:

The XML resolves to:

<id= "myerrorendevent">  <errorref  = "Myerror"/></endevent>

The myerror referenced by ERRORREF is configured in error:

<id= "Myerror"  errorCode= "123"/>... <  ID= "myprocess">...

Where error ErrorCode will be matched to the boundary event, if Errorref is not found for the error,errorref will be the short name of ErrorCode, which is unique in Activiti, such as:

<ErrorID= "Myerror"ErrorCode= "error123" />...<ProcessID= "Myprocess">...  <endeventID= "Myerrorendevent">    <erroreventdefinitionErrorref= "Myerror" />  </endevent>...

is equivalent to:

<id= "myerrorendevent">  <errorref  = "error123"/></endevent>
8.2.3 Terminate End Event

When the process executes to the Terminate End event, both the current process and the sub-process will end. Conceptually, when executing to a terminating end event, the process instance and the subprocess end, and in BPMN2.0, a sub-process can be embedded in the sub-process, the sub-process with the transaction, which applies to the general situation. When, for example, multiple instances call an active or embedded sub-process, only that instance will end, and other instances and process instances are unaffected. Design visualizations In Process Designer are:

Parse to XML:

<id= "Myendevent >  <terminateeventdefinition activiti:terminateall=" true " ></ terminateeventdefinition > </ endevent >

Activiti Workflow Learning-----Based on 5.19.0 version (8)

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.