Activiti BPM 6 internal flow architecture

cancel
Showing results for 
Search instead for 
Did you mean: 
rohitrocks26
Member II

Activiti BPM 6 internal flow architecture

I am new to this Activiti 6 .. I am just trying to understand how activiti engine executes the flow..I know that it parse the xml file aand store in process def and byte array table.. But internally how Activiti engine knows that after this event trigger the next one ?  

Lets say if this is my xml
<process id="myProcess" name="My process" isExecutable="true">
<startEvent id="startevent1" name="Start" activiti:initiator="initiator"></startEvent>
<exclusiveGateway id="decide" name="num"></exclusiveGateway>
<scriptTask id="scripttask2" name="Script Task" scriptFormat="groovy" activiti:autoStoreVariables="false">
<script>outSmiley Tonguerintln "Hello !!! Number is greater than 10";</script>
</scriptTask>
<scriptTask id="scripttask3" name="Script Task" scriptFormat="groovy" activiti:autoStoreVariables="false">
<script>outSmiley Tonguerintln "Hello !!! Number is less than 10";</script>
</scriptTask>
<sequenceFlow id="flow3" name="&lt;10" sourceRef="decide" targetRef="scripttask3">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${num < 10}]]></conditionExpression>
</sequenceFlow>
<sequenceFlow id="flow4" name="&gt;10" sourceRef="decide" targetRef="scripttask2">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${num > 10}]]></conditionExpression>
</sequenceFlow>
<userTask id="usertask1" name="Enter any number" activiti:assignee="${initiator}" activiti:candidateGroups="managers">
<extensionElements>
<activiti:formProperty id="num" name="num" type="long" required="true"></activiti:formProperty>
</extensionElements>
</userTask>
<sequenceFlow id="flow6" sourceRef="usertask1" targetRef="decide"></sequenceFlow>
<endEvent id="endevent1" name="End"></endEvent>
<sequenceFlow id="flow7" sourceRef="scripttask2" targetRef="endevent1"></sequenceFlow>
<sequenceFlow id="flow8" sourceRef="scripttask3" targetRef="endevent1"></sequenceFlow>
<sequenceFlow id="flow9" sourceRef="startevent1" targetRef="usertask1"></sequenceFlow>
</process>

How it works internally ?? Cn anyone help me to understand this?

1 Reply
ryandawson
Alfresco Employee

Re: Activiti BPM 6 internal flow architecture

If the process doesn't involve any listening to anything external so the sequence is moved on because the engine is orchestrating every step. The execution of all the script tasks is initiated by the engine and likewise for the conditions. (Though the implementation is different for each - the engine architecture needs to make room for lots of different types of work to be done - you can get a bit of a picture of this variety in the source code at Activiti/activiti-engine/src/main/java/org/activiti/engine/impl/cmd at develop · Activiti/Activiti ·... .) For the user tasks the engine does have to stop and wait for input. In that case the state is persisted to the database and only gets started again when there is user input, which ultimately will mean that a java process calls an engine API to make it start. All of the state changes are captured through the database.

The engine has different APIs for different ways of interacting with it - you can see a diagram of them at Activiti User Guide  . I guess it's the runtimeService you are most interested in (RuntimeService (Activiti - Engine 5.22.0 API) ). Again the source code is available to look at Activiti/RuntimeServiceImpl.java at develop · Activiti/Activiti · GitHub and you can see how the RuntimeService is just part of the picture if you browse up a level from that link to Activiti/activiti-engine/src/main/java/org/activiti/engine/impl at develop · Activiti/Activiti · Git... 

Gvien the importance of the database I'd recommend chapter 15 of Activiti in Action. Or indeed the whole book. My impression is that you are not saying you've read the whole book and not had your questions answered - instead my impression is that you want to jump to particular topics that you are trying to understand quickly. Maybe you would be better to try it out more and get more comfortable with it. Or maybe you have further reasons for asking these particular questions (perhaps you are wondering how well Activiti will perform with large volumes)? If you are wondering about higher level questions like that it might be better to ask them directly (e.g. if you're interested in performance you could look at The Activiti Performance Showdown | Small steps with big feet ).