In process automation, you often encounter deviations from the default scenario. One way to resolve these deviations is using a BPMN error event, which allows a process model to react to errors within a task.
For example, if an invalid credit card is used in the process below, the process takes a different path than usual and uses the default payment method to collect money.
Defining the error
In BPMN, errors define possible errors that can occur. Error events are elements in the process referring to defined errors. An error can be referenced by one or more error events.
An error must define an errorCode
(e.g. InvalidCreditCard
). The errorCode
is a string
used to match a thrown error to the error catch events.
Throwing the error
An error can be thrown within the process using an error end event.
Alternatively, you can inform Zeebe that a business error occurred using a client command. This throw error client command can only be used while processing a job.
In addition to throwing the error, this also disables the job and stops it from being activated or completed by other job workers. See the gRPC command for details.
Catching the error
A thrown error can be caught by an error catch event, specifically using an error boundary event or an error event subprocess.
Starting at the scope where the error was thrown, the error code is matched against the attached error boundary events and error event sub processes at that level. An error is caught by the first event in the scope hierarchy matching the error code. At each scope, the error is either caught, or propagated to the parent scope.
If the process instance is created via call activity, the error can also be caught in the calling parent process instance.
Error boundary events and error event subprocesses must be interrupting. This means the process instance will not continue along the regular path, but instead follow the path that leads out of the catching error event.
If the error is thrown for a job, the associated task is terminated first. To continue the execution, the error boundary event or error event subprocess that caught the error is activated.
Unhandled errors
When an error is thrown and not caught, an incident (i.e. Unhandled error event
) is raised to indicate the failure. The incident is attached to the corresponding element where the error was thrown (i.e. the task of the processed job or the error end event).
When you resolve the incident attached to a task, it ignores the error, re-enables the job, and allows it to be activated and completed by a job worker once again.
The incident attached to an error end event cannot be resolved by a user because the failure is in the process itself. The process cannot be changed to catch the error for this process instance.
Business error vs. technical error
In real life, you’ll also have to deal with technical problems that you don’t want to treat using error events.
Suppose the credit card service becomes temporarily unavailable. You don’t want to model the retrying, as you would have to add it to each and every service task. This will bloat the visual model and confuse business personnel. Instead, either retry or fall back to incidents as described above. This is hidden in the visual.
In this context, we found the terms business error and technical error can be confusing, as they emphasize the source of the error too much. This can lead to long discussions about whether a certain problem is technical or not, and if you are allowed to see technical errors in a business process model.
It’s much more important to look at how you react to certain errors. Even a technical problem can qualify for a business reaction. For example, you could decide to continue a process in the event that a scoring service is not available, and simply give every customer a good rating instead of blocking progress. The error is clearly technical, but the reaction is a business decision.
In general, we recommend talking about business reactions, which are modeled in your process, and technical reactions, which are handled generically using retries or incidents.
Additional resources
XML representation
A boundary error event:
<bpmn:error id="invalid-credit-card-error" errorCode="Invalid Credit Card" />
<bpmn:boundaryEvent id="invalid-credit-card" name="Invalid Credit Card" attachedToRef="collect-money">
<bpmn:errorEventDefinition errorRef="invalid-credit-card-error" />
</bpmn:boundaryEvent>
References
- Incidents
Error events are events which are triggered by a defined error.
Business Errors vs. Technical Errors
A BPMN error is meant for business errors — which are different than technical exceptions. So, this is different than Java exceptions — which are, by default, handled in their own way.
You might also want to check out the basics of Threading and Transactions in the User Guide first.
Defining an Error
An error event definition references an error element. The following is an example of an error end event, referencing an error declaration:
<definitions>
<error id="myError" errorCode="ERROR-OCCURED" name="ERROR-OCCURED"/>
<!-- ... -->
<process>
<!-- ... -->
<endEvent id="myErrorEndEvent">
<errorEventDefinition errorRef="myError" />
</endEvent>
</process>
</definitions>
You can trigger this error event either with a throwing error event within your process definition or from Delegation Code, see the
Throwing BPMN Errors from Delegation Code section of the User Guide for more information.
Another possibility to define an error is setting of the type (class name) of any Java Exception as error code. Example:
<definitions>
<error id="myException" errorCode="com.company.MyBusinessException"
name="myBusinessException"/>
<!-- ... -->
<process>
<!-- ... -->
<endEvent id="myErrorEndEvent">
<errorEventDefinition errorRef="myException" />
</endEvent>
</process>
</definitions>
The exception type should only be used for business exceptions and not for technical exceptions in the process.
An error event handler references the same error element to declare that it catches the error.
It is also possible to define an error message with the camunda:errorMessage
extension for an error element to give further information about the error.
The referencing error event definition must specify camunda:errorMessageVariable
to receive the error message. The error message can also contain expressions.
<definitions>
<error id="myError" errorCode="ERROR-OCCURED" name="ERROR-OCCURED"
camunda:errorMessage="Something went wrong: ${errorCause}" />
<!-- ... -->
<process>
<!-- ... -->
<endEvent id="myErrorEndEvent">
<errorEventDefinition errorRef="myError" camunda:errorMessageVariable="err"/>
</endEvent>
</process>
</definitions>
When the error thrown by the error end event is catched a process variable with the name err
will be created that holds the evaluated message.
For External Tasks, it is also possible to define error events by using a camunda:errorEventDefinition as shown in the following example. It additionally requires an expression that must evaluate to true
in order for the BPMN error to be thrown. For further details on how to use those error events, consult the External Tasks Guide.
<serviceTask id="validateAddressTask"
name="Validate Address"
camunda:type="external"
camunda:topic="AddressValidation" >
<extensionElements>
<camunda:errorEventDefinition id="addressErrorDefinition"
errorRef="addressError"
expression="${externalTask.getErrorDetails().contains('address error found')}" />
</extensionElements>
</serviceTask>
Error Start Event
An error start event can only be used to trigger an Event Sub-Process — it cannot be used to start a process instance. The error start event is always interrupting.
Three optional attributes can be added to the error start event: errorRef
, camunda:errorCodeVariable
and camunda:errorMessageVariable
:
<definitions>
<error id="myException" errorCode="com.company.MyBusinessException" name="myBusinessException"/>
...
<process>
...
<subProcess id="SubProcess_1" triggeredByEvent="true">>
<startEvent id="myErrorStartEvent">
<errorEventDefinition errorRef="myException" camunda:errorCodeVariable="myErrorVariable"
camunda:errorMessageVariable="myErrorMessageVariable" />
</startEvent>
...
</subProcess>
...
</process>
</definitions>
- If
errorRef
is omitted, the subprocess will start for every error event that occurs. - The
camunda:errorCodeVariable
will contain the error code that was specified with the error. - The
camunda:errorMessageVariable
will contain the error message that was specified with the error.
camunda:errorCodeVariable
and camunda:errorMessageVariable
can be retrieved like any other process variable, but only if the attribute was set.
Error End Event
When process execution arrives at an error end event, the current path of execution is ended and an error is thrown. This error can be caught by a matching intermediate error boundary event. In case no matching error boundary event is found, the execution semantics defaults to the none end event semantics.
Camunda Extensions
Error Event Definition
Attributes |
camunda:asyncBefore, camunda:asyncAfter, camunda:errorCodeVariable, camunda:errorMessageVariable, camunda:exclusive, camunda:jobPriority |
---|---|
Extension Elements | camunda:inputOutput |
Constraints | – |
Error Definition
Attributes | camunda:errorMessage |
---|---|
Extension Elements | – |
Constraints | – |
Error Boundary Event
An intermediate catching error event on the boundary of an activity, or error boundary event for short, catches errors that are thrown within the scope of the activity on which it is defined.
Defining a error boundary event makes most sense on an embedded subprocess, or a call activity, as a subprocess creates a scope for all activities inside the subprocess. Errors are thrown by error end events. Such an error will propagate its parent scopes upwards until a scope is found on which a error boundary event is defined that matches the error event definition.
When an error event is caught, the activity on which the boundary event is defined is destroyed, also destroying all current executions therein (e.g., concurrent activities, nested subprocesses, etc.). Process execution continues following the outgoing sequence flow of the boundary event.
A error boundary event is defined as a typical boundary event. As with the other error events, the errorRef references an error defined outside of the process element:
<definitions>
<error id="myError" errorCode="ERROR-OCCURED" name="name of error"/>
<!-- ... -->
<process>
<!-- ... -->
<subProcess id="mySubProcess">
<!-- ... -->
</subProcess>
<boundaryEvent id="catchError" attachedToRef="mySubProcess">
<errorEventDefinition errorRef="myError" camunda:errorCodeVariable="myErrorVariable"
camunda:errorMessageVariable="myErrorMessageVariable" />
</boundaryEvent>
</process>
</definitions>
The errorCode is used to match the errors that are caught:
- If errorRef is omitted, the error boundary event will catch any error event, regardless of the errorCode of the error.
- In case an errorRef is provided and it references an existing error, the boundary event will only catch errors with the defined error code.
- If the errorCodeVariable is set, the error code can be retrieved using this variable.
- If the errorMessageVariable is set, the error message can be retrieved using this variable.
Unhandled BPMN Error
It can happen that no catching boundary event was defined for an error event. The default behaviour in this case is to log information and end the current execution.
This behaviour can be changed with enableExceptionsAfterUnhandledBpmnError
property set to true
(via the process engine configuration or the deployment descriptor) and Process Engine Exception will be thrown if unhandled BPMN Error occurs.
Catch and Re-Throw Pattern
An error can be handled by the error start event in the event sub process and the same error can be thrown from the event sub process to handle the error on the higher level scope (in the example below, the error thrown from the Event Subprocess is handled by the error boundary event in the Subprocess).
Additional Resources
- Error Events in the BPMN 2.0 Modeling Reference
- Incidents in the User Guide
title | weight | menu | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
Error Events |
50 |
|
Error events are events which are triggered by a defined error.
Business Errors vs. Technical Errors
A BPMN error is meant for business errors — which are different than technical exceptions. So, this is different than Java exceptions — which are, by default, handled in their own way.
You might also want to check out the basics of [Threading and Transactions]({{< ref «/user-guide/process-engine/transactions-in-processes.md#transaction-boundaries» >}}) in the [User Guide]({{< ref «/user-guide/_index.md» >}}) first.
Defining an Error
An error event definition references an error element. The following is an example of an error end event, referencing an error declaration:
<definitions> <error id="myError" errorCode="ERROR-OCCURED" name="ERROR-OCCURED"/> <!-- ... --> <process> <!-- ... --> <endEvent id="myErrorEndEvent"> <errorEventDefinition errorRef="myError" /> </endEvent> </process> </definitions>
You can trigger this error event either with a throwing error event within your process definition or from Delegation Code, see the
[Throwing BPMN Errors from Delegation Code]({{< ref «/user-guide/process-engine/delegation-code.md#throw-bpmn-errors-from-delegation-code» >}}) section of the [User Guide]({{< ref «/user-guide/_index.md» >}}) for more information.
Another possibility to define an error is setting of the type (class name) of any Java Exception as error code. Example:
<definitions> <error id="myException" errorCode="com.company.MyBusinessException" name="myBusinessException"/> <!-- ... --> <process> <!-- ... --> <endEvent id="myErrorEndEvent"> <errorEventDefinition errorRef="myException" /> </endEvent> </process> </definitions>
The exception type should only be used for business exceptions and not for technical exceptions in the process.
An error event handler references the same error element to declare that it catches the error.
It is also possible to define an error message with the <a href=»{{< ref «/reference/bpmn20/custom-extensions/extension-attributes.md#errormessage» >}}»>camunda:errorMessage
extension for an error element to give further information about the error.
The referencing error event definition must specify <a href=»{{< ref «/reference/bpmn20/custom-extensions/extension-attributes.md#errormessagevariable» >}}»>camunda:errorMessageVariable
to receive the error message. The error message can also contain <a href=»{{< ref «/user-guide/process-engine/expression-language.md» >}}»>expressions.
<definitions> <error id="myError" errorCode="ERROR-OCCURED" name="ERROR-OCCURED" camunda:errorMessage="Something went wrong: ${errorCause}" /> <!-- ... --> <process> <!-- ... --> <endEvent id="myErrorEndEvent"> <errorEventDefinition errorRef="myError" camunda:errorMessageVariable="err"/> </endEvent> </process> </definitions>
When the error thrown by the error end event is catched a process variable with the name err
will be created that holds the evaluated message.
For External Tasks, it is also possible to define error events by using a [camunda:errorEventDefinition]({{< ref «/reference/bpmn20/custom-extensions/extension-elements.md#erroreventdefinition» >}}) as shown in the following example. It additionally requires an expression that must evaluate to true
in order for the BPMN error to be thrown. For further details on how to use those error events, consult the [External Tasks Guide]({{< ref «/user-guide/process-engine/external-tasks.md#error-event-definitions» >}}).
<serviceTask id="validateAddressTask" name="Validate Address" camunda:type="external" camunda:topic="AddressValidation" > <extensionElements> <camunda:errorEventDefinition id="addressErrorDefinition" errorRef="addressError" expression="${externalTask.getErrorDetails().contains('address error found')}" /> </extensionElements> </serviceTask>
Error Start Event
An error start event can only be used to trigger an Event Sub-Process — it cannot be used to start a process instance. The error start event is always interrupting.
Three optional attributes can be added to the error start event: errorRef
, camunda:errorCodeVariable
and camunda:errorMessageVariable
:
<definitions> <error id="myException" errorCode="com.company.MyBusinessException" name="myBusinessException"/> ... <process> ... <subProcess id="SubProcess_1" triggeredByEvent="true">> <startEvent id="myErrorStartEvent"> <errorEventDefinition errorRef="myException" camunda:errorCodeVariable="myErrorVariable" camunda:errorMessageVariable="myErrorMessageVariable" /> </startEvent> ... </subProcess> ... </process> </definitions>
- If
errorRef
is omitted, the subprocess will start for every error event that occurs. - The
camunda:errorCodeVariable
will contain the error code that was specified with the error. - The
camunda:errorMessageVariable
will contain the error message that was specified with the error.
camunda:errorCodeVariable
and camunda:errorMessageVariable
can be retrieved like any other process variable, but only if the attribute was set.
Error End Event
When process execution arrives at an error end event, the current path of execution is ended and an error is thrown. This error can be caught by a matching intermediate error boundary event. In case no matching error boundary event is found, the execution semantics defaults to the none end event semantics.
Camunda Extensions
Error Event Definition
Attributes |
}}»>camunda:asyncBefore, }}»>camunda:asyncAfter, }}»>camunda:errorCodeVariable, }}»>camunda:errorMessageVariable, }}»>camunda:exclusive, }}»>camunda:jobPriority |
---|---|
Extension Elements | }}»>camunda:inputOutput |
Constraints | – |
Error Definition
Attributes | }}»>camunda:errorMessage |
---|---|
Extension Elements | – |
Constraints | – |
Error Boundary Event
An intermediate catching error event on the boundary of an activity, or error boundary event for short, catches errors that are thrown within the scope of the activity on which it is defined.
Defining a error boundary event makes most sense on an embedded subprocess, or a call activity, as a subprocess creates a scope for all activities inside the subprocess. Errors are thrown by error end events. Such an error will propagate its parent scopes upwards until a scope is found on which a error boundary event is defined that matches the error event definition.
When an error event is caught, the activity on which the boundary event is defined is destroyed, also destroying all current executions therein (e.g., concurrent activities, nested subprocesses, etc.). Process execution continues following the outgoing sequence flow of the boundary event.
A error boundary event is defined as a typical boundary event. As with the other error events, the errorRef references an error defined outside of the process element:
<definitions> <error id="myError" errorCode="ERROR-OCCURED" name="name of error"/> <!-- ... --> <process> <!-- ... --> <subProcess id="mySubProcess"> <!-- ... --> </subProcess> <boundaryEvent id="catchError" attachedToRef="mySubProcess"> <errorEventDefinition errorRef="myError" camunda:errorCodeVariable="myErrorVariable" camunda:errorMessageVariable="myErrorMessageVariable" /> </boundaryEvent> </process> </definitions>
The errorCode is used to match the errors that are caught:
- If errorRef is omitted, the error boundary event will catch any error event, regardless of the errorCode of the error.
- In case an errorRef is provided and it references an existing error, the boundary event will only catch errors with the defined error code.
- If the errorCodeVariable is set, the error code can be retrieved using this variable.
- If the errorMessageVariable is set, the error message can be retrieved using this variable.
Unhandled BPMN Error
It can happen that no catching boundary event was defined for an error event. The default behaviour in this case is to log information and end the current execution.
This behaviour can be changed with enableExceptionsAfterUnhandledBpmnError
property set to true
(via the process engine configuration or the deployment descriptor) and Process Engine Exception will be thrown if unhandled BPMN Error occurs.
Catch and Re-Throw Pattern
An error can be handled by the error start event in the event sub process and the same error can be thrown from the event sub process to handle the error on the higher level scope (in the example below, the error thrown from the Event Subprocess is handled by the error boundary event in the Subprocess).
Additional Resources
- Error Events in the BPMN 2.0 Modeling Reference
- [Incidents]({{< ref «/user-guide/process-engine/incidents.md» >}}) in the [User Guide]({{< ref «/user-guide/_index.md» >}})
Online Modeler
Our modeler is an online and desktop tool for designing, discussing and sharing BPMN diagrams with your team.
Try Modeler
Overview
BPMN Symbol Overview
Artifacts
Data
Activities
Task
Subprocess
Call Activity
Event
Subprocess
Transaction
Events
Heads up!
For understanding the principle behavior of events in BPMN, check out Events: Basic Concepts.
Start | Intermediate | End | ||||||
---|---|---|---|---|---|---|---|---|
Type | Normal | Event Sub process |
Event Sub process non- interrupt |
Catch | Boundary | Boundary non- interrupt |
Throw | |
None |
Start Event |
|||||||
Message |
Message Start Event |
Message Event Subprocess |
Message Event Subprocess Non-interrupt |
Message Event Catch |
Message Event Boundary |
Message Event Boundary non-interrupt |
Message Event Throw |
Message End Event |
Timer |
Timer Start Event |
Timer Event Subprocess |
Timer Event Subprocess non-interrupt |
Timer Event Catch |
Timer Event Boundary |
Timer Event Boundary non-interrupt |
||
Conditional |
conditional start event |
conditional event subprocess |
conditional event subprocess non-interrupt |
conditional catch event |
conditional boundary event |
conditional throw event |
||
Link |
link catch event |
link throw event |
||||||
Signal |
signal start event |
signal event Subprocess |
signal event Subprocess non-interrupt |
signal catch event |
signal boundary event |
signal boundary non-interrupt event |
signal throw event |
signal end event |
Error |
error event subprocess |
error boundary event |
error end event |
|||||
Escalation |
escalation event subprocess |
escalation event subprocess non-interrupt |
escalation boundary event |
escalation boundary non-interrupt event |
escalation throw event |
escalation end event |
||
Termination |
termination end event |
|||||||
Compensation |
compensation event subprocess |
compensation boundary event |
compensation throw event |
compensation end event |
||||
Cancel |
cancel boundary event |
cancel end event |
||||||
Multiple |
multiple start event |
multiple event Subprocess |
multiple event Subprocess non-interrupt |
multiple catch event |
multiple boundary event |
multiple boundary non-interrupt event |
multiple throw event |
multiple end event |
Multiple Parallel |
multiple parallel start event |
multiple parallel event subprocess |
multiple parallel event subprocess non-interrupt |
multiple parallel catch event |
multiple parallel boundary event |
multiple parallel boundary non-interrupt event |
Participants
Introducing Pools, the conductor and the orchestra
We already described how to use lanes to assign responsibility for tasks or subprocesses to different task managers. Lanes always exist in a pool, and the lane boundaries represent process boundaries from start to end. To BPMN, the pool represents a higher-ranking instance compared to its lanes. The pool assumes process control – in other words, it assigns the tasks. It behaves like the conductor of an orchestra, and so this type of process is called “orchestration.”
In the diagram below, the “conductor” arranges for Falko to process task 2 as soon as Robert completes task 1. The conductor has the highest-level control of the process, and each instrument in the orchestra plays the tune the conductor decides upon:
process conductor
Robert
start
task 1
Stefan
task 4
Christian
task 3
Falko
task 2
Do you think this is unrealistic? Many experienced process modelers have problems with this way of thinking. They would prefer to model a process sequence like that shown below on the assumption that no almighty conductor exists in their company, and that individual process participants have to coordinate and cooperate on their own:
Robert
start
task 1
passing on to
Falko
Stefan
task 4
Christian
task 3
passing on to
Stefan
Falko
task 2
passing on to
Christian
But to coordinate cooperation with BPMN requires explicit modeling. You assign each task manager a separate pool, and the process passes from one to the next as a message flow as shown in below. In principle, this creates four independent conductors. These have control over their respective mini-processes, but they can’t do anything other than to send messages that trigger their successor processes:
Stefan
task 4
start
Christian
task 3
passing on to
Stefan
start
Falko
task 2
passing on to
Christian
start
Robert
start
task 1
passing on to
Falko
That seems complicated – and you don’t have to choose this method for practical modeling. It reveals a basic principle, however, that you must understand. Even though BPMN lanes look very much like those of other process notations, they represent an entirely different way of thinking, which we attribute to BPMN’s origin in the world of process automation. In that world, the process engine controls all tasks in the process, even though different task managers may execute them. So the process engine equates to the mysterious, almighty process conductor.
Have you heard of service orchestration in connection with Service Oriented Architecture (SOA)? That’s almost exactly the task of a process engine, except that these services are not only fully automated web services; they also can be tasks executed by human process participants as directed by the process engine. What does that signify, however, for purely functional process modeling, in which you also describe processes not controlled by such a process engine? There’s no general answer to that question.
You can eliminate pools and work just with lanes, modeling the message exchange as normal tasks as shown before. That’s traditional, and it’s a pragmatic solution during, say, a transitional period that allows your co-workers to adapt. In the medium and long terms, however, avoiding pools denies you a powerful device for increasing the significance of process models.
We will show the usefulness of this new thinking by example. One thing to remember is that if you strive to harmonize your functional and technical process models to achieve a better alignment of business and IT, you inevitably face this type of process modeling whether you use BPMN or not.
Pools: The art of collaboration
We already examined the process represented below in connection with the event-based gateway:
Now consider the broader picture, and think about how this process happens from the point of view of the pizza delivery service. Presumably, it looks like here: As soon as we receive an order, we bake the pizza. Our delivery person takes it to the customer and collects the money, whereby the process completes successfully.
pizza sales
supplier
pizza baker
Order
received
bake pizza
delivery boy
deliver pizza
take the money
end
We want to link the two processes, that is, to examine the interaction of customer and delivery service from a neutral perspective. We can try to model this interaction by means of a pool and lanes as in here:
pizza- process
customer
hunger
noticed
choose pizza
order pizza
pizza
received
eat pizza
call pizza
delivery service
60 minutes
pizza received
supplier
pizza baker
bake pizza
delivery boy
deliver pizza
take the
money
But this doesn’t work well: There are tasks and events that reference interaction within the pool – waiting for the delivery, for instance, or collecting the money. Other tasks are carried out by roles oblivious to their partners, such as baking the pizza and eating the pizza. It is impossible to differentiate the two visually. Strictly speaking, the diagram is not semantically correct because message events always refer to messages received by the process from outside, and that’s not the case here.
If we go with pools, the whole process looks like below. Both processes in the combined representation would look just as they did before, but now they connect through message flows. BPMN calls this form of visualization a collaboration diagram. It shows two independent processes collaborating.
pizza sale
supplier
Lieferjunge
deliver pizza
take
the money
end
Pizza-Bäcker
bake pizza
order received
pizza order
customer
hunger
noticed
choose pizza
order pizza
eat pizza
hunger
satisfied
pizza received
60 minutes
pizza received
call pizza
delivery service
In two cases, the message flows do not end in an activity or event, but at the participants’ respective pool boundaries. The first one comes from the “inquire at delivery service” task; the second one connects to the “collect money” task. The rationale behind the first one is that our inquiry does not influence the sequence flow of the deliverer. The pizza service may provide information or speed up its order processing in anticipation of a new order, but the baking, delivering, and collecting of money doesn’t change just because an inquiry came in. As for the “collect money” messages, there’s a flaw in the model of the customer process: we have to pay for the pizza before we eat it, and that task is still missing. We added it to the diagram below, and now we can connect the message flows directly to the “pay for pizza” task.
pizza sales
supplier
delivery boy
deliver pizza
end
take
the money
pizza baker
bake pizza
order
received
pizza order
customer
hunger
noticed
choose pizza
order pizza
eat pizza
hunger
satisfied
pizza received
60 minutes
call pizza
delivery service
pay for pizza
Create your own model or check out the “Order and Deliver Pizza” example diagram with Camunda’s free online modeler.
Collapsing Pools
It often happens that we don’t know the processes of all parties in detail. We may know the processes of our own company, for example, but not those of a partner company. As long as our partner and we adhere to agreed-upon interfaces, such as receiving or sending certain messages, things can still operate smoothly. As customers of the pizza delivery service, we expect the deliverer to:
- Accept pizza orders,
- Deliver ordered pizzas and collect the money, and
- Be available for inquiries.
As customers, we have little interest in the deliverer’s internal process. Maybe he bakes and then delivers the pizza; maybe when he’s out of supplies, he gets another pizza service to bake the pizza and deliver it. That’s his problem – we simply expect to receive our pizza. In modeling such cases, we can hide the deliverer’s process and collapse the pool:
pizza order
customer
hunger
noticed
choose pizza
order pizza
eat pizza
hunger
satisfied
pizza
received
60 minutes
call pizza
delivery service
pay for pizza
pizza
received
supplier
We could go a step further and collapse the customer’s pool too. Now we see only the messages to be exchanged, assuming that we label the arrows to give us the general idea. The downside is that we can’t recognize interdependencies any more. We can’t see if the inquiry always goes out, or only takes place under certain conditions – the actual case:
pizza delivery – supplier
pizza order – customer
inquiry
order
take the money
delivery
pay
Lanes
We have talked about what to do in our processes, but we have not yet explained who is responsible for executing which tasks. In BPMN, you can answer this question with lanes.
Hover over orange symbols for explanation
flat-sharing community
Robert
prepare salad
Falko
cook steak
Christian
hunger
noticed
choose recipe
desired dish?
cook pasta
eat meal
hunger
satisfied
desired
component?
salad
steak
pasta
something
real
The diagram shows that the tasks in our sample process were assigned to particular people. We can derive the following process description from the assignments: If Christian is hungry, he chooses a certain recipe. Depending on what Christian chooses, he can either take care of it himself (cook pasta), or he can get his roommates on board. If the latter, Falko cooks steak and Robert prepares salad. In the end, Christian eats. The three lanes (Christian, Falko, Robert) are united in one pool designated “flat-sharing community.”
FAQ: Do I have to label a lane with a concrete person? |
In the example, lanes equate to people, but this meaning is not specified by BPMN. You can designate the lanes as you like. In practice, lanes are often used to assign:
|
Activities
Task
So far, we have used only tasks of undefined types, though BPMN provides the opportunity to work with task types just as it does for event types. Primarily, task types are intended to model processes that are technically executable. Task types are applied infrequently in practice. We know from experience, however, that task types can be particularly useful when modeling engineering requirements.
Hover over orange symbols for explanation
undefined
manual
user
receive
receive
(instantiated)
send
script
service
business rule
Task Markers
In addition to those various types of tasks, we can mark tasks as loops, multiple instances, or compensations. Markers can be combined with the assigned types.
Loop
A loop task repeats until a defined condition either applies or ceases to apply. Perhaps we suggest various dishes to our dinner guests until everyone agrees. Then, we can prepare the meal:
time for
dinner
suggest dish
prepare meal
meal
prepared
until everyone
agrees
In the example, we executed the task first and checked afterwards to see if we needed it to execute again. Programmers know the principle as the “do-while” construct. We can also apply a “while-do” construct, however, and so check for a condition before the task instead of afterward. This occurs rarely, but it makes sense if the task may not execute at all.
You can attach the condition on which a loop task executes for the first time or, as shown in the example, apply the condition on repeated executions as an annotation to the task. You can store this condition as an attribute in a formal language of your BPMN tool as well. That makes sense if the process is to be executed by a process engine.
Multiple Instance
The individual cycles of a loop task must follow each other. If for example we live in a flat-sharing community and the roommates feel like eating pizza, the “choose pizza” task must be repeated for each roommate before we can order. You’d sit together and pass a menu around until finally everyone has made a decision. There are student apartments where they do handle it like that – more evidence that students have too much time on their hands! It is much more efficient for all roommates to look at the menu at once, and they choose a pizza together. You can model this process using the “multiple task” (see below). A multiple task instantiates repeatedly and can be executed in sequence or in parallel, with the latter being the more interesting case.
shared flat
craves pizza
choose pizza
order pizza
pizza
ordered
everyone in the
flat
Do you think the example is absurd? How does your company check invoices for group orders, such as for office supplies? Do you forward the invoice from one employee to the next, so that each person can sign off on the items he or she ordered, before you pay the invoice? If so, you live in a flat-sharing community, and you urgently should consider optimizing your process. Automating invoices is still one of the top BPM projects, and the top goal of such projects often is one of parallelization.
Compensation
We explain the benefit of the compensation event by means of an example. The compensation task type is applied exclusively in the context of a compensation event. Accordingly, it is integrated in the process diagram only by associations, never by sequence flows.
The possible combination of the compensation with a loop or multiple instance as shown below is worth mentioning. In this case, both markers are placed in parallel. As with the other markers, the compensation can be combined with the task types already introduced. A manual compensation task that repeats until it succeeds or that executes repeatedly and in parallel as far as possible, is therefore eminently practical.
…
book trip
…
cancel trip
…
invite all
friends via
mass email
…
uninvite
everyone via
phonecall
manual loop
compensation
manual parallel
compensation
call the travel agency
again and again until it
carves in
Subprocess
Encapsulate complexity
The examples in this tutorial either deal with simple processes, or they diagram complex processes superficially so that the models fit on one page. When modeling your process landscape, you don’t have this luxury. You have to rough out your processes so that you can get the general ideas in place and recognize correlations. Then you have to develop a detailed description, so that you can analyze exactly where the weak points are or how you’ll have to execute the process in practice. The possible top-down refinements or bottom-up aggregations mark the difference between true process models and banal flow charts, between sophisticated BPM software products and mere drawing programs.
BPMN provides us with the subprocess to help with the expanding/collapsing view. A subprocess describes a detailed sequence, but it takes no more space in the diagram of the parent process than does a task. Both tasks and subprocesses are part of the activities class and are therefore represented as rectangles with rounded corners. The only difference is the plus sign, indicating a stored detailed sequence for the subprocess:
main process
start
task
subprocess
end
What good is that to us? That depends most on how your BPMN tool supports the following options for connecting subprocesses with their parent processes:
- Representation in a separate process diagram: The subprocess symbol links to a separate diagram. If your BPMN tool displays the process model in a web browser, for instance, clicking on the symbol would open a new page to display the detail diagram.
- Expanding in the process diagram of the parent process: The activity with the plus sign is called a collapsed subprocess. The plus sign suggests that you could click on it and make the subprocess expand. The BPMN specification provides for this option, though not all tool suppliers implement it. The diagram below shows how the subprocess was directly expanded in the diagram of the parent process. A tool supporting this function enables you to expand and collapse the subprocess directly in the diagram, respectively, to show or hide details.
main process
start
end
task
subprocess
task
task
Direct expansion may seem appealing, but often it is not useful in practice. Expanding the subprocess requires that all the adjacent symbols in the diagram shift to make room. This can result in sluggish performance with a complex diagram, and it can be visually nasty. The most important thing is that your tool provides for linking and that you can usefully navigate through the diagrams. In other words, it supports the first option above. Yes, it can be helpful to have your subprocess modeled and expandable directly from the parent process. That means process segments remain localized, and you can attach events too. This is, however, the less important option.
The sequence flow of the parent process ends in both cases at the left edge of the subprocess. The next sequence flow starts at the right edge. This means that sequence flows are not allowed to exceed the boundaries of the subprocess, which not every beginner knows, and which becomes a problem when a subprocess expands. Visualize a token that behaves as follows:
- The parent process starts, and a token is born.
- The token runs through the task and arrives at the subprocess, which causes the parent process to create an instance of the subprocess.
- Within the subprocess, a separate token is born which runs through the subprocess from the start to the end event, but the token of the parent process waits until the subprocess completes.
- When the subprocess token arrives at the end event, it is consumed, which completes the subprocess. Now the token of the parent process moves to its own end event.
The encapsulation in subprocesses that we’re describing isn’t restricted to two levels. You could just as easily have a parent process as a subprocess, or you could model further subprocesses on the level of a defined subprocess. How many levels you use and the level of detail you apply to model them is up to you. BPMN doesn’t specify this, and there can be no cross-company or cross-scenario cookbook to define levels. Participants in our BPMN workshops don’t like this, but there’s no point in hiding the fact nor attempting to explain it away. In the following chapters, we work often with subprocesses in explaining our best practices, but the truth is the number of refinement levels and their respective levels of detail is always situational. It depends on the organization, the roles of the project participants, and the goals for the process you’re modeling.
Attaching Events
We already learned about intermediate events that can be attached to tasks. The same events can be attached to subprocesses as well, which opens up a wide range of opportunity in process modeling. As shown in the diagram below, we can represent how a spontaneous dinner invitation leads to canceling our cooking process. In the process shown, however, we could ignore the invitation if our meal had already been prepared and we are already eating it:
hunger
noticed
choose recipe
prepare meal
eat meal
go out for dinner
hunger
satisfied
Where message, timer, and conditional events are involved, the parent process always aborts the subprocess when reacting to external circumstances. With error, cancellation, and escalation events, however, the subprocess reports these events to the parent process. This isn’t as abstract as it may sound.
stock maintenance
minimum stock
level reached
procurement
article
procured
delete article
from catalogue
article
deleted
order processing
order
received
check
availability
article
available?
ship article
financial
management
end
inform
customer
delete article
from catalogue
end
procurement
procurement
start
place order
available?
expect delivery
…
not
available
not
available
not
available
yes
no
yes
no
In the bottom right of the diagram above, the item procurement task can fail because the item is no longer available. Because item procurement is a global subprocess, it triggers an error event to tell the parent process that something went wrong. In business terms, this may mean that the customer who wanted to buy the item tells a salesperson that his or her order failed because the item is out of stock.
It is interesting that parent processes can handle the error message differently. While the disappointed customer must be informed within the scope of the order process, it is sufficient for the stock maintenance process to delete the item from the catalog. The respective parent processes decide what circumstances require canceling the subprocess and what happens next. That’s a principle that you can use to build flexible and modular process landscapes.
The signal event serves two functions. A parent process can react to a signal received from the outside while it executes a subprocess – this is much like a message event. But we also use the signal event to let the subprocess communicate things other than errors to the parent process. Primarily, this is because we can’t model this type of communication with message events. BPMN assumes that we always send messages to other participants who are outside of our pool boundaries; the communication between parent and subprocess doesn’t fit that mold. We don’t use signal events for directed communication, but rather to broadcast information akin to advertisements on the radio.
A better alternative provided in BPMN 2.0 is the escalation event. The subprocess can use an escalation event to report directly to the parent process, and the message won’t be regarded as an error message. Also, the parent process can receive and process messages from escalation events without canceling the subprocess because non-interrupting intermediate events can be attached:
order processing
order
received
check
availability
article
available?
ship article
financial
management
end
inform
customer
delete article
from catalogue
end
procurement
inform
customer
end
not available
procurement
start
place order
available?
expect delivery
…
not
available
late
delivery
late delivery
yes
no
in< 2
days
in> 2
days
no
Call Activity
Modularization and reuse
In version 1.2, BPMN differentiated between embedded and reusable subprocesses by assigning an attribute to a subprocess. In version 2.0, BPMN maintains this differentiation in principle, but it is defined differently. A subprocess now is embedded intrinsically, and it can be reused only by defining it as a global subprocess, and then referencing it by means of a call activity. We therefore refer to embedded subprocesses and global subprocesses in the following.
An embedded subprocess can occur only within a parent process to which it belongs. An embedded subprocess cannot contain pools and lanes, but it can be placed within the pool or the lane of the parent process. Furthermore, an embedded subprocess may have only a none start event; start events such as messages or timers are not permitted. An embedded subprocess has essentially nothing more than a kind of delimited scope within the parent process, which may serve two goals:
- To encapsulate complexity (as already described)
- To formulate a “collective statement” on a part of the parent process by attaching events or placing markers. We deal with this option later.
On the other hand, global subprocesses may occur in completely different parent processes. There are a great many subprocesses that, in practice, are used over and over. A good example is the procurement of an item because a customer ordered it or you need to re-stock supply. Another example is invoicing because you’ve delivered or repaired an item as shown in the diagram below. In the example, notice that call activities differ from regular activities by their considerably thicker borders:
financial settlement
start
send invoice
…
…
payment
received
term of payment
exceeded
order processing
check
availability
order
received
article
available?
ship article
end
article
procurement
financial
settlement
stock maintenance
minimum stock
levle reached
article
procured
article
procurement
repair
repair order
received
carry out repair
end
financial
management
article procurement
start
place order
…
yes
no
The connection a global subprocesses has to its parent is considerably less close, and they can have their own pools and lanes. You can think of the participant responsible for a subprocess as a service provider for various parent processes. It is a like a shared service center.
The loose connection also affects data transfer between the parent and the subprocess. BPMN assumes that embedded subprocesses can read all the data of the parent process directly, but an explicit assignment is required for global subprocesses to be able to read it. That may seem like merely a technical aspect at first, one that modelers and the consumers of their models care to know about but won’t wish to bother with. After some consideration, however, you may see the impact this difference makes on the organization. Consider this: When your accounting department wants to issue an invoice for a repair, it always needs:
- A billing address
- The date of performance delivery
- A description of performance
- An amount to invoice
- An expected date of payment
The owners of order processing, not just the repair department, must provide this data. Accounting will want the data in a standard format, won’t it? This corresponds well to what BPMN calls required data mapping between parent processes and global subprocesses. (Do you notice how often these weird techie issues correspond to the organizational needs and expectations of a process?) BPMN simply forces us to formalize many matters that seem self-evident, or that remained unconscious or forgotten in the process design. Formalization is our best chance of keeping up in a fast-changing environment with ever more complex processes.
Adhoc
One marker available only for subprocesses is called ad-hoc. Recognize it by the tilde character as shown in the diagram below:
2 days before
departure
switch off
heating
create auto
response
give key to
neighbour
pack bags
…
Use the ad-hoc subprocess to mark a segment in which the contained activities (tasks or subprocesses) can be:
- Executed in any order,
- Executed several times, or
- Skipped.
Any party who executes this subprocess decides what to do and when to do it. You could say that the “barely structured” nature of what happens inside this subprocess reduces the whole idea of process modeling to an absurdity because what happens and when are the things we most want to control. On the other hand, this is the reality of many processes, and you can’t model them without representing their free-form character. Frequent examples are when a process relies largely on implicit knowledge or creativity, or when different employees carry out a process differently. You can use the ad-hoc subprocess to flag what may be an undesirable actual state. Doing so could be a step on the path to a more standardized procedure.
BPMN 2.0 specifies which symbols must, which may, and which are forbidden to occur within an ad-hoc subprocess. They are:
- Must: Activities
- May: Data objects, sequence flows, associations, groups, message flows, gateways, and intermediate events
- Forbidden: Start and end events, symbols for conversations and choreographies
By means of the specification, mixed forms – so-called weakly structured processes – can be modeled as shown in here:
textbook shall be writtenrecruitauthorsplan contentsresearch topicswrite textcreate graphicsinclude graphics into textreleasecontributiongeneratemanuscriptmanuscriptcompleteeach author!
Event Subprocess
BPMN 2.0 introduced a completely new construct, the event subprocess. We locate an event subprocess within another process or subprocess. Recognize them by their dotted-line frames.
A single start event always triggers an event subprocess, and this can only happen while the enclosing process or subprocess remains active. For event subprocesses, there can be interrupting (continuous line) and non-interrupting (dashed line) events. This is the same differentiation made as for attached intermediate events. Depending on the type of start event, the event subprocess will cancel the enclosing subprocess, or it will execute simultaneously. You can trigger non-interrupting event subprocesses as often as you wish, as long as the enclosing subprocess remains active.
Okay, that’s pretty abstract, but we can demonstrate how an event subprocess works with an example:
invite friends for
dinner
meal preparations
include guest
a new guest has
announced himself
take new guest
into account
provide meal
cooking meal
failed
order meal
choose recipe
prepare meal
eat meal
We invited a couple of friends for dinner. This starts the “dinner preparation” subprocess of choosing a recipe and then preparing the meal. While we are doing that, the telephone rings. Another guest invites himself to dinner. Spontaneous as we are, we just increase the amount of food or set another place at the table without interrupting the meal preparation. If an accident happens during preparation, however, the error immediately triggers the interrupting event subprocess for remedial action. We order food for delivery. When this event subprocess completes, we exit the enclosing subprocess through the regular exit and attend to eating the meal.
You can see below how event subprocesses are represented in collapsed state: The frame is a dotted line, and we have again used the plus sign to represent collapsed subprocesses. In the top left corner, we also have the start event triggering the subprocess.
invite friends for
dinner
meal preparations
choose recipe
prepare meal
include guest
provide meal
eat meal
The event types that can trigger both interrupting and non-interrupting event subprocesses are:
- Message
- Timer
- Escalation
- Conditional
- Signal
- Multiple
- Multiple parallel
There are two more types for the interrupting event subprocesses:
- Error
- Compensation
Gateways
Data-based Exclusive Gateways
Hover over orange symbols for explanation
hunger
noticed
choose recipe
desired
dish?
cook pasta
cook steak
prepare salad
eat meal
pasta
steak
salad
Certain things can only be done under certain circumstances, so few processes always take the same course. In our simple example, we want to go into the details of cookery. Driven by hunger, we think about what we are going to cook today. We only know three recipes, so we choose one. We can either cook pasta or cook a steak or prepare a salad. Let’s say that these options are exclusive – we will never prepare more than one at a time. The point of decision on what to do next is called gateway. We decide based on available data (the chosen recipe) and we follow only one of the paths, which is a data-based exclusive gateway. We abbreviate “exclusive gateway” as XOR.
Heads up!
Bear in mind that a gateway is not a task! You have to determine facts and needs before reaching a gateway.
Best Practice: Naming Conventions
As in the diagram above, we place the crucial question before the gateway. This is our convention, which has proved its value in our projects. Possible answers go on parallel paths after the gateway, which is how the BPMN specification shows them. We always work with XOR gateways as follows:
- Model the task that requires a decision for the XOR gateway.
- Model the XOR gateway after that.
- Create a question with mutually exclusive answers.
- Model one outgoing path (or sequence flow) for each possible answer, and label the path with the answer.
FAQ: Do I have to draw the “X”-Marker inside the rhombus? I have already seen that symbol without any marker…
BPMN uses two symbols for XOR gateways:
They are identical in meaning. We always use the version with the X because it seems less ambiguous.
Parallel Gateways
Suppose that now we want a salad on the side. If you want salad no matter what, you could model it as we have done in this diagram:
Hover over orange symbols for explanation
hunger
noticed
choose recipe
prepare salad
desired
dish?
cook pasta
cook steak
eat meal
20 minutes
10 minutes
10 minutes
3 minutes
15 minutes
pasta
steak
The total of the task times equals the running time of the process, which was a total of 48 minutes for pasta and 43 minutes for steak. Congratulations: you’ve just analyzed your first process based on key data!
Still, this means waiting 23 or even 28 minutes until you can start to eat. Insufferable! You’re really hungry, but what can you do? Maybe you don’t prepare the salad first and then cook the pasta or the steak, but you work on both at the same time – in parallel. The appropriate symbol is the parallel gateway, or the “AND gateway” for short, as shown in here:
Hover over orange symbols for explanation
hunger
noticed
Choose recipe
Desired dish?
Cook pasta
cook steak
prepare salad
Eat meal
Hunger
satisfied
10 Minutes
10 Minutes
20 Minutes
3 Minutes
15 Minutes
Pasta
Steak
Diagramming tasks as parallel does not make simultaneous processing compulsory. In contrast to the example shown before, it is also not imperative that you prepare the salad before starting other tasks. Parallel preparation does, however, reduce our total time by 10 minutes. It is classic process optimization to make tasks parallel as much as possible.
Check yourself: What if we draw the same process, but leave the AND merge out for lack of space, and the path from the “prepare salad” task leads directly to the XOR merge. What happens if we instantiate the process, and we decide in favor of pasta?
The token is generated and then cloned as always at the AND split. As soon as we finish preparing the salad, the token passes through the XOR merge and “eat meal” executes. Five minutes later,”cook pasta” also completes. Its token passes through the XOR merge and “eat meal” executes again! That’s not the behavior we wanted.
hunger
noticed
Choose recipe
Desired dish?
Cook pasta
cook steak
prepare salad
Eat meal
Hunger
satisfied
10 Minutes
10 Minutes
20 Minutes
3 Minutes
15 Minutes
Pasta
Steak
Data-based inclusive gateways
We want to make our process even more flexible: When we are hungry, we want to eat
- Only a salad,
- A salad and “something real,” like pasta or steak, or
- Only something real.
If you want a more compact representation, you can use the data-based inclusive gateway – the OR gateway for short:
Hover over orange symbols for explanation
hunger
noticed
choose recipe
desired
components?
prepare salad
cook pasta
desired dish?
cook steak
eat meal
hunger
satisfied
20 minutes
3 minutes
15 minutes
10 minutes
10 minutes
salad
steak
pasta
something real
Heads up! In practice, handling OR gateways is not as simple as these examples imply. It’s easy to understand that progress depends on waiting for another token to reach an OR merge. It can be harder to trace the synchronization rules with complex diagrams that sprawl across several pages.
Event-based Gateways
We learned about the exclusive data-based (XOR) gateway option as a way to use different paths with regard to the data being processed. Users of other process notations recognize this type of branching, but BPMN gives us another way to design process paths: the event-based gateway – event gateway, for short. This gateway does not route based on data, but rather by which event takes place next. To understand the benefit, consider the process shown below: We order pizza and wait for it to be delivered. We can eat only after we receive the pizza, but what if the pizza doesn’t arrive after 60 minutes? We’ll make an anxious phone call, that’s what! We can model this with the event gateway:
Hover over orange symbols for explanation
hunger
noticed
choose pizza
order pizza
pizza received
eat pizza
pizza received
call pizza
delivery service
60 minutes
hunger
satisfied
As you can see here, not all intermediate events combine with the event gateway. You can, however, combine it with the receive task.
…
message
…
time
…
condition
…
signal
…
multiple
…
receive task
…
Events
Basic Concepts
Tasks and gateways are two of three flow elements we’ve come to know so far: Things (tasks) have to be done under certain circumstances (gateways). What flow element is still missing? The things (events) that are supposed to happen. Events are no less important for BPMN process models than tasks or gateways. We should start with some basic principles for applying them. We already saw Start events, intermediate events, and end events. Those three event types are also catching and/or throwing events:
Catching events are events with a defined trigger. We consider that they take place once the trigger has activated or fired. As an intellectual construct, that is relatively intricate, so we simplify by calling them catching events. The point is that these events influence the course of the process and therefore must be modeled. Catching events may result in:
- The process starting
- The process or a process path continuing
- The task currently processed or the sub-process being canceled
- Another process path being used while a task or a sub-process executes
Throwing events are assumed by BPMN to trigger themselves instead of reacting to a trigger. You could say that they are active compared to passive catching events. We call them throwing events for short, because the process triggers them. Throwing events can be:
- Triggered during the process
- Triggered at the end of the process
We can also model attached intermediate events with BPMN. These do not explicitly require waiting, but they do interrupt our activities, both tasks and sub-processes. Such intermediate events are attached because we position them at the boundary of the activity we want to interrupt.
Hover over orange symbols for explanation
…
task 1
task 2
…
task 3
…
event 1
A token running through the process would behave this way:
- The token moves to task 1, which starts accordingly.
- If event 1 occurs while task 1 is being processed, task 1 is immediately canceled, and the token moves through the exception flow to task 3.
- On the other hand, if event 1 does not occur, task 1 will be processed, and the token moves through the regular sequence flow to task 2.
- If event 1 occurs only after task 1 completes, it will be ignored.
Through BPMN version 1.2, with the exception of compensation events, attached intermediate events inevitably resulted in canceled activities. BPMN 2.0 defines a new symbol: the non-interrupting intermediate event. It sounds awkward, but it is useful:
Hover over orange symbols for explanation
…
task 1
task 2
…
task 3
…
event 1
The token moves through the process as follows:
- The token moves to task 1, which starts accordingly.
- If event 1 occurs while task 1 is being processed, the token is cloned. Task 1 continues to be processed while the second token moves to task 3, which is now also processed. This procedure may even take place repeatedly, that is, the event can occur many times. Each occurrence results in another cloned token.
- If event 1 does not occur, task 1 will be completed, and the token moves through the regular sequence flow to task 2.
- If event 1 occurs only after task 1 completes, it ceases to matter.
In the following sections, we introduce the event types to be used when working with BPMN. We also explain how you can react to different events using the event-based gateway.
Message
Sooner or later, most processes require communication, which can be represented in BPMN by means of the message event. You’ll recognize it as the small envelope. The meaning of “message” in BPMN is not restricted to letters, e-mails, or calls. Any action that refers to a specific addressee and represents or contains information for the addressee is a message.
Hover over orange symbols for explanation
hunger
noticed
choose pizza
order pizza
pizza
received
eat pizza
hunger
satisfied
FAQ: Could I replace the task “order pizza” with a throwing message event?
Yes, you could:
hunger
noticed
choose pizza
pizza
ordered
pizza
received
eat pizza
hunger
satisfied
Heads up! We are not always happy with the throwing intermediate event. Implying a “send message” task without modeling it explicitly can easily confuse inexperienced consumers of our models. We choose not to use throwing intermediate events for messages and instead use a task. There are also special BPMN task types for sending and receiving messages.
In the example below, we show a message leading to cancellation. In this scenario, we administer a web application. When a user notifies us that the website does not work, we immediately search for the error. But maybe the user is mistaken, and the website is fine. Maybe the user’s Internet connection is defective. If the user tells us about the false alarm, we cancel the search and swear at the user for wasting our time. If the error is actually found, however, we eliminate it and simultaneously figure out who caused the error. If the user caused the error, we can swear at the user for a different reason. If the user is not at fault, however, we thank him or her graciously for letting us know about the problem.
user reports:
“website
is down!”
search for bug
fix bug
users
fault?
insult user
user insulted
thank user
user thanked
user reports:
“sorry, false
alarm!”
yes
no
Timer
The timer event is often used when working with BPMN because it is so flexible to apply. A clock icon represents the timer event. The diagram below shows a few examples of applications:
holidays
2 months
prior to trip
choose
destination
book trip
pack bags
…
2 days
prior to trip
user support
every 2
hours
check email
inbox
view most
important topic
handle most
important topic
…
coffee break
10 minutes
working day
Monday-Friday
at 07 am
get up
do morning
toilette
take bus to work
…
08 am
Valentine 2010
02/14/2010
08 am
get up
buy bouquet
wake beloved
with bouquet
…
02/14/2010
09 am
Time moves on no matter what we or our processes do, so timer events can exist only as catching starts or intermediate events.
You can model countdown times with an attached timer event. They are used this way frequently. You can specify upper time limits – the maximum time allowed for a processing task – for instance:
Hover over orange symbols for explanation
hunger
noticed
choose pizza
order pizza
pizza
received
eat meal
cook pasta
30 minutes
hunger
satisfied
Non-interrupting timer events became possible with BPMN 2.0:
Hover over orange symbols for explanation
hunger
noticed
choose recipe
prepare meal
set table
eat meal
hunger
satisfied
10 minutes prior
to completion
Error
Do your processes run completely error-free? If not, you can identify potential errors in your models as a step toward eliminating them, or as part of modeling escalation processes. In BPMN, error events are represented by a flash symbol.
The BPMN specification does not specify what an error may be. As the modeler, you have to decide that.
An error is a serious event in BPMN, so if catching, it can be modeled only as an attached intermediate event. This means that an error during task execution must be handled in a specific way: As a throwing event, it can be modeled only at the end of a process path so that the participant knows the process has failed. The parent process should likewise recognize the failure.
You can find example of error events e.g. in the Implementation section for “Event Subprocesses”.
Conditional
Sometimes we only want a process to start or to continue if a certain condition is true. Anything can be a condition, and conditions are independent of processes, which is why the condition (like the timer event) can only exist as a catching event. A process cannot therefore conditional event trigger a conditional event.
We can enhance our pizza process with conditions. If we want to have frozen pizza, the process starts as shown in the diagram below. We take the pizza from the freezer and turn on the oven. But only after the temperature in the oven reaches 180 C do we put the pizza in, and only after it is done do we take it out to eat.
frozen pizza
desired
take pizza from
freezer
switch on oven
oven to 180°
put pizza in oven
pizza
ready
eat pizza
hunger
satisfied
Signal
Signals are similar to messages, which is why you can model them in BPMN as events just as you can with messages. The symbol for a signal is a triangle. The essential difference between a signal and a message is that that latter is always addressed to a specific recipient. (An e-mail contains the e-mail address of the recipient, a call starts with dialing the telephone number, and so on.) In contrast, a signal is more like a newspaper advertisement or a television commercial. It is relatively undirected. Anyone who receives the signal and wants to react may do so.
pizza spot
seen on TV
buy pizza
get an appetite
for pizza
eat pizza
evaluate pizza
on pizzatest.de
We saw a new frozen pizza on TV, and we are keen to try it. The diagram above illustrates this new situation. We buy the pizza, but we keep it in the freezer until we’re really hungry for pizza. That’s a conditional event. After trying the new pizza, we go to Pizzatest.de to rate the new product. That’s a signal. It is a signal for the general public too. (Pizzatest.de actually exists, by the way, which proves again that you can find simply everything on the Internet!)
Termination
Let’s look at the abstract example below. We already discussed (simple) Key Performance Indicator (KPI) analysis, and we therefore know that this process always takes 55 minutes. After task 1, tasks 2 and 3 can be processed simultaneously. Processing task 2 takes more time than does processing task 3, which is why it determines the runtime of the process. A token that runs through the process is cloned in the AND split. The first token stays in task 2 for 45 minutes; the second token stays in task 3 for 30 minutes. The second token arrives at the none event first, where it is consumed. After 15 more minutes, the first token arrives at the upper none event, where it is consumed too. Since no more tokens are available, the process instance finishes after 55 minutes.
start
task 1
task 2
end 1
task 3
end 2
30 minutes
45 minutes
10 minutes
So far, so good, but what happens if we already know that, after having completed task 3, task 2 has become redundant? This is a frequent situation with parallel task executions related to content. In such cases, we can apply the pattern shown in here:
Hover over orange symbols for explanation
start
task 1
task 2
end 1
task 3
task 2 no longer
necessary?
end 2
termination
45 minutes
30 minutes
10 minutes
no
yes
Link
The link event is a special case. It has no significance related to content, but it facilitates the diagram-creation process. As shown below, you can draw two associated links as an alternative to a sequence flow. Here, “associated” means there is a throwing link event as the “exit point,” and a catching link event as the “entrance point,” and the two events are marked as a pair – in our example by the designation “A.”
…
task 1
A
A
task 2
…
…
task 1
task 2
…
=
Link events can be very useful if:
- You have to distribute a process diagram across several pages. Links orient the reader from one page to the next.
- You draw comprehensive process diagrams with many sequence flows. Links help avoid what otherwise might look like a “spaghetti” diagram.
Link events can be used as intermediate events only.
Compensation
We execute tasks in our processes that sometimes have to be canceled later under certain circumstances.
Typical examples are:
- Booking a train or airline ticket
- Reserving a rental car
- Charging a credit card
- Commissioning a service provider
Below, we see this process: On Friday at 1 p.m. we agree with our partner either to go to the theater or to spend the evening with friends. In both cases, we have to do something binding, either to reserve the theater tickets or make the arrangements with our friends. When evening arrives, perhaps we no longer feel like going out at all. We then have to cancel the arrangements we made with the theater or our friends before we can collapse in front of the TV in peace:
Friday 1 pm
arrange date
planned
activities?
book theatre
tickets
arrange date
with friends
Friday 6 pm
still wanting
to go?
carry out activity
what was
the plan?
cancel theatre
tickets
watch TV
cancel friends
theatre
friends
yes
no
theatre
friends
We can represent the latter part of the model more compactly with a compensation event, as shown in here:
Hover over orange symbols for explanation
Friday 1 pm
arrange date
planned
activities?
book theatre
tickets
arrange date
with friends
cancel friends
Friday 6 pm
still wanting
to go?
carry out activity
cancel
activity
watch TV
cancel theatre
tickets
theatre
friends
yes
no
There are special rules for handling compensations:
- Throwing compensations refer to their own processes, so the event is effective within the pool. This shows how this event type differs from a throwing message event.
- Other attached events can take effect only while the activities to which they are attached remain active. In contrast, an attached compensation takes effect only if the process triggers a compensation and the activity to which the compensation is attached successfully completed.
- Attached compensation events connect to compensation tasks through associations, and not through sequence flows, which would otherwise be common usage. BPMN thus emphasizes that compensations are beyond the regular process sequence; executing one is an exception.
Best Practice: Using Compensation Events
This example may be too simple to illustrate how much work this construct can save you. If you think of the complex business processes that frequently require compensations, however, you’ll see how much leaner your models can be. You’ll also be quick to spot the circumstances that demand compensations. We use compensation events only occasionally to describe complex processes.
Multiple
We can use the multiple event to summarize several events with a single symbol. The diagram below applies the multiple event to our pizza scenario. In the example, we try a new pizza after having seen it on TV or after a friend recommended it. After eating it, we will rate the pizza on Pizzatest.de and in turn inform our friend if we also recommend this pizza.
Hover over orange symbols for explanation
pizza comercial seen on TV or friend recommended pizza buy pizzacrave pizzaeat pizza
pizza onpizzatest.de evaluated and link sent to friend
Best Practice: Avoiding Multiple Events
You have to decide if multiple events serve your purposes. We concede their benefit in rough functional process descriptions, but they cease to be as useful in the more advanced technical-implementation phase. You can’t afford to leave relevant details hiding in the descriptive text. We don’t find the multiple event to be intuitive, nor is it helpful on a functional level. It may make your diagrams larger to model all events separately, but the resulting diagrams will be both more comprehensive and more comprehensible. The bottom line is that we have never used this symbol in practice, nor have we seen anybody else doing so.The model in here describes the same process, but the events are fully modeled:
pizza commercial seen on TVfriend recommended pizza buy pizzacrave pizzaeat pizzaevaluate pizzaon pizzatest.desend evaluationto friend
Parallel
The parallel event was added in BPMN 2.0 to supplement the multiple event. While a catching multiple event has XOR semantics – it occurs as soon as one of its contained events occurs – the parallel event uses AND semantics. It doesn’t occur until all of its contained events occur. Because the throwing multiple event already implies AND semantics, the specification defines parallel events as catching events only.
Escalation
The BPMN 2.0 specification added the escalation event. Mainly, it shows communication between parent and sub-processes.
Cancel
You can use the cancel event only in the context of the transactions.
In this tutorial, we are going to learn about how to handle exceptions in Camunda. For this
Create a Spring Boot project with the embedded Camunda Engine using this link. Use version 7.15.0.
Other Requirements
- Spring Boot 2.4.3
- Camunda 7.15.0
- Eclipse or any other IDE
- Maven
Handle Exceptions in Camunda
Import the Maven project into Eclipse and add the required dependencies.
- Create service task in Camunda modeler and add error catch event to that service task.
- Whenever an exception occurred in the service task, an error catch event will catch the exception and throws that service task into the respective journey flow.
- If you did not give any error catch event it will be created as an incident in the cockpit and the token will be rolled back to the start event.
Use Camunda modeler to save the below XML content with the .bpmn extension to get the process model, which is having an error catch event.
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_12zbd5u" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.5.0">
<bpmn:collaboration id="Collaboration_1vtn4s6">
<bpmn:participant id="Participant_18yien5" name="Error Handling" processRef="Process_1jtu8ae" />
</bpmn:collaboration>
<bpmn:process id="Process_1jtu8ae" isExecutable="true">
<bpmn:startEvent id="StartEvent_1">
<bpmn:outgoing>Flow_0vs3b46</bpmn:outgoing>
</bpmn:startEvent>
<bpmn:endEvent id="Event_08wul9s">
<bpmn:incoming>Flow_0kby2yc</bpmn:incoming>
</bpmn:endEvent>
<bpmn:sequenceFlow id="Flow_0vs3b46" sourceRef="StartEvent_1" targetRef="Activity_0snk7cd" />
<bpmn:sequenceFlow id="Flow_0kby2yc" sourceRef="Activity_0snk7cd" targetRef="Event_08wul9s" />
<bpmn:serviceTask id="Activity_0snk7cd" name="Service Task" camunda:delegateExpression="${ServiceTaskDelegate}">
<bpmn:incoming>Flow_0vs3b46</bpmn:incoming>
<bpmn:outgoing>Flow_0kby2yc</bpmn:outgoing>
</bpmn:serviceTask>
<bpmn:sequenceFlow id="Flow_0qbi7m4" sourceRef="Event_01bk0vq" targetRef="Event_0my2aab" />
<bpmn:boundaryEvent id="Event_01bk0vq" attachedToRef="Activity_0snk7cd">
<bpmn:outgoing>Flow_0qbi7m4</bpmn:outgoing>
<bpmn:errorEventDefinition id="ErrorEventDefinition_1eepl13" errorRef="Error_00fdfpv" camunda:errorCodeVariable="code_variable" />
</bpmn:boundaryEvent>
<bpmn:endEvent id="Event_0my2aab">
<bpmn:incoming>Flow_0qbi7m4</bpmn:incoming>
<bpmn:errorEventDefinition id="ErrorEventDefinition_1hkclb7" errorRef="Error_00fdfpv" />
</bpmn:endEvent>
</bpmn:process>
<bpmn:error id="Error_00fdfpv" name="BPMN_ERROR" errorCode="error_code" />
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Collaboration_1vtn4s6">
<bpmndi:BPMNShape id="Participant_18yien5_di" bpmnElement="Participant_18yien5" isHorizontal="true">
<dc:Bounds x="129" y="52" width="600" height="316" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="Flow_0qbi7m4_di" bpmnElement="Flow_0qbi7m4">
<di:waypoint x="390" y="228" />
<di:waypoint x="390" y="290" />
<di:waypoint x="462" y="290" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0kby2yc_di" bpmnElement="Flow_0kby2yc">
<di:waypoint x="440" y="170" />
<di:waypoint x="512" y="170" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0vs3b46_di" bpmnElement="Flow_0vs3b46">
<di:waypoint x="278" y="170" />
<di:waypoint x="340" y="170" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
<dc:Bounds x="242" y="152" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_08wul9s_di" bpmnElement="Event_08wul9s">
<dc:Bounds x="512" y="152" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_0h53qgw_di" bpmnElement="Activity_0snk7cd">
<dc:Bounds x="340" y="130" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_1vjkbhx_di" bpmnElement="Event_0my2aab">
<dc:Bounds x="462" y="272" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_18eo0oc_di" bpmnElement="Event_01bk0vq">
<dc:Bounds x="372" y="192" width="36" height="36" />
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
After copy-pasting the above XML file in the Camunda modeler you can see the below diagram.
Add the below snippet to the exception handling
Run the application using the main class file and observe the output where the exception is caught by the error catch event and passed through the error throws event.
Opinions expressed by DZone contributors are their own.
- Business Errors vs. Technical Errors
- Defining an Error
- Error Start Event
- Error End Event
- Camunda Extensions
- Error Boundary Event
- Unhandled BPMN Error
- Catch and Re-Throw Pattern
- Additional Resources
- Additional Resources
Error events are events which are triggered by a defined error.
Business Errors vs. Technical Errors
A BPMN error is meant for business errors — which are different than technical exceptions. So, this is different than Java exceptions — which are, by default, handled in their own way.
You might also want to check out the basics of Threading and Transactions in the User Guide first.
Defining an Error
An error event definition references an error element. The following is an example of an error end event, referencing an error declaration:
<definitions>
<error id="myError" errorCode="ERROR-OCCURED" name="ERROR-OCCURED"/>
<!-- ... -->
<process>
<!-- ... -->
<endEvent id="myErrorEndEvent">
<errorEventDefinition errorRef="myError" />
</endEvent>
</process>
</definitions>
You can trigger this error event either with a throwing error event within your process definition or from Delegation Code, see theThrowing BPMN Errors from Delegation Code section of the User Guide for more information.
Another possibility to define an error is setting of the type (class name) of any Java Exception as error code. Example:
<definitions>
<error id="myException" errorCode="com.company.MyBusinessException" name="myBusinessException"/>
...
<process>
...
<endEvent id="myErrorEndEvent">
<errorEventDefinition errorRef="myException" />
</endEvent>
</process>
</definitions>
The exception type should only be used for business exceptions and not for technical exceptions in the process.
An error event handler references the same error element to declare that it catches the error.
Error Start Event
An error start event can only be used to trigger an Event Sub-Process — it cannot be used to start a process instance. The error start event is always interrupting.
Three optional attributes can be added to the error start event: errorRef
, camunda:errorCodeVariable
and camunda:errorMessageVariable
:
<definitions>
<error id="myException" errorCode="com.company.MyBusinessException" name="myBusinessException"/>
...
<process>
...
<subProcess id="SubProcess_1" triggeredByEvent="true">>
<startEvent id="myErrorStartEvent">
<errorEventDefinition errorRef="myException" camunda:errorCodeVariable="myErrorVariable"
camunda:errorMessageVariable="myErrorMessageVariable" />
</startEvent>
...
</subProcess>
...
</process>
</definitions>
- If errorRef is omitted, the subprocess will start for every error event that occurs.
- The camunda:errorCodeVariable will contain the error code that was specified with the error.
- The camunda:errorMessageVariable will contain the error message that was specified with the error.
camunda:errorCodeVariable
andcamunda:errorMessageVariable
can be retrieved like any other process variable, but only if the attribute was set.
Error End Event
When process execution arrives at an error end event, the current path of execution is ended and an error is thrown. This error can be caught by a matching intermediate error boundary event. In case no matching error boundary event is found, the execution semantics defaults to the none end event semantics.
Camunda Extensions
Attributes |
---|
camunda:asyncBefore, camunda:asyncAfter, camunda:errorCodeVariable, camunda:errorMessageVariable, camunda:exclusive, camunda:jobPriority |
Extension Elements |
——- |
camunda:inputOutput |
Constraints |
——- |
– |
Error Boundary Event
An intermediate catching error event on the boundary of an activity, or error boundary event for short, catches errors that are thrown within the scope of the activity on which it is defined.
Defining a error boundary event makes most sense on an embedded subprocess, or a call activity, as a subprocess creates a scope for all activities inside the subprocess. Errors are thrown by error end events. Such an error will propagate its parent scopes upwards until a scope is found on which a error boundary event is defined that matches the error event definition.
When an error event is caught, the activity on which the boundary event is defined is destroyed, also destroying all current executions therein (e.g., concurrent activities, nested subprocesses, etc.). Process execution continues following the outgoing sequence flow of the boundary event.
A error boundary event is defined as a typical boundary event. As with the other error events, the errorRef references an error defined outside of the process element:
<definitions>
<error id="myError" errorCode="ERROR-OCCURED" name="name of error"/>
<!-- ... -->
<process>
<!-- ... -->
<subProcess id="mySubProcess">
<!-- ... -->
</subProcess>
<boundaryEvent id="catchError" attachedToRef="mySubProcess">
<errorEventDefinition errorRef="myError" camunda:errorCodeVariable="myErrorVariable"
camunda:errorMessageVariable="myErrorMessageVariable" />
</boundaryEvent>
</process>
</definitions>
The errorCode is used to match the errors that are caught:
- If errorRef is omitted, the error boundary event will catch any error event, regardless of the errorCode of the error.
- In case an errorRef is provided and it references an existing error, the boundary event will only catch errors with the defined error code.
- If the errorCodeVariable is set, the error code can be retrieved using this variable.
- If the errorMessageVariable is set, the error message can be retrieved using this variable.
Unhandled BPMN Error
It can happens that no catching boundary event was defined for an error event. The default behaviour in this case is to log information and end the current execution.This behaviour can be changed with enableExceptionsAfterUnhandledBpmnError
property set to true
(via the process engine configuration or the deployment descriptor) and Process Engine Exception will be thrown if unhandled BPMN Error occurs.
Catch and Re-Throw Pattern
An error can be handled by the error start event in the event sub process and the same error can be thrown from the event sub process to handle the error on the higher level scope (in the example below, the error thrown from the Event Subprocess is handled by the error boundary event in the Subprocess).
Additional Resources
- Error Events in the BPMN 2.0 Modeling Reference
- Incidents in the User Guide
原文: https://docs.camunda.org/manual/7.9/reference/bpmn20/events/error-events/
В этом году вышел релиз Camunda 8 — это последнее обновление мажорной версии платформы за минувшие семь лет. В статье я поделюсь собственным опытом работы в «восьмерке» и расскажу об основных отличиях от предыдущей версии, но при этом не полезу глубоко «под капот», а опишу их глазами аналитика.
Олег Саверкин
Аналитик IRLIX
Мой коллега Сергей, бекенд-разработчик, ёмко и в то же время достаточно точно определил основную суть и назначение этого инструмента:
«Совместное использование BPMN и Camunda приводит к наибольшей степени вовлеченности участников разработки в бизнес-процессы, к более детальному пониманию всех цепочек процессов, и в итоге — к получению командного компаса по лабиринтам процессов».
Camunda — тот самый Low-Code, который дает много готовых решений для автоматизации бизнес-процессов «из коробки». Не буду здесь подробно их расписывать: возможности платформы хорошо описаны на официальном сайте. Важно понимать, что Camunda — это BPMN и Java.
Если использование языка Java дает широкий простор для творчества разработчикам, то BPMN позволяет остальным членам команды лучше понимать друг друга. Почему? — Наличие диаграмм обеспечивают необходимую наглядность, что обеспечивает лучшее понимание логики бизнес-процессов.
Существует множество роликов и публикаций, посвященных платформе Camunda и опыту ее применения в различных проектах. В этих материалах достаточно подробно описаны сложности и ошибки, с которыми сталкиваются команды на практике, а также есть рекомендации, как их избежать. Эти советы сохраняют свою актуальность и сегодня, но при одном условии: важно учитывать изменения, которые появились с выходом новой версии Camunda. С некоторыми из них, существенными для задач аналитика, познакомимся ниже.
Что нового и какие вопросы вызывает восьмая версия
Как уже было отмечено, члены проектной команды взаимодействуют, опираясь на BPMN-диаграммы, которые позволяют всем одинаково понимать логику бизнес-процессов.
BPMN также помогает взаимодействовать с представителями бизнеса: заказчик после вводной демонстрации и необходимых пояснений понимает нотацию и достаточно хорошо ориентируется в элементах диаграммы. Бывает и такое, что заказчик сам знает и активно использует BPMN.
Тем не менее, обилие элементов нотации (~480 элементов), в частности большое количество событий и шлюзов, может сбить с толку команду и вызвать затруднения при работе со схемами бизнес-процессов.
Хорошая новость как раз в том, что в восьмой версии Camunda сократили число элементов, доступных для построения диаграмм.
Что же изменилось?
События (Эвенты)
Из новой версии исключили:
1. Стартовые события следующих типов:
- conditional start event;
- signal start event (от сигналов, к слову, вообще отказались).
2. Промежуточные события следующих типов:
- escalation intermediate throw event;
- conditional intermediate catch event;
- link intermediate catch event;
- link intermediate throw event;
- compensation intermediate throw event;
- signal intermediate catch event;
- signal intermediate throw event.
3. Завершающие события следующих типов:
- escalation end event;
- compensation end event;
- signal end event.
4. terminate end event — пожалуй, самая большая потеря, так как «terminate end event» — достаточно удобная штука. На мой взгляд :).
4. Boundary events следующих типов:
- escalation boundary event;
- conditional boundary event;
- compensation boundary event;
- signal boundary event;
- escalation boundary event (non-interrupting);
- conditional boundary event (non-interrupting);
- signal boundary event (non-interrupting).
А что осталось?
1. Помимо простых событий каждого вида по-прежнему доступны:
- message start event;
- timer start event;
- message intermediate catch event;
- message intermediate throw event;
- timer intermediate event;
- message end event;
- error end event.
2. А также следующий набор boundary events:
- message boundary event;
- timer boundary event;
- error boundary event;
- message boundary event (non-interrupting);
- timer boundary event (non-interrupting).
Шлюзы
Шлюзы следующих типов также не поддерживаются новой версией платформы:
- inclusive gateway;
- complex gateway.
Доступны только:
- parallel gateway;
- event based gateway;
- exclusive gateway.
Таски
Набор доступных тасков не изменился. Изменения затронули внутреннюю структуру.
Одно из заметных преобразований — отсутствие блока «Implementation» среди атрибутов сервис-таска. Его заменили на «Task definition», который теперь не содержит предопределенных типов. К примеру, необходимости указывать «JavaClass» больше нет: не таск ссылается на «JavaClass», а сам код обращается к нужному таску. А для сервис-таска достаточно указать атрибут type и число попыток запуска в случае неудачи — атрибут retries (по умолчанию равен 3).
Camunda 7
Camunda 8
Такое решение по началу сбивает с толку, но по своей сути оно намного ближе к Low-Code по сравнению с тем, что было в предыдущей версии.
Коннекторы
Появились коннекторы, своего рода Low-Code интеграции, которые разделяют на:
- Входящие — позволяют запустить какой-либо процесс извне (снаружи);
- Исходящие — позволяют обращаться к сторонним системам.
Выделяют также коннекторы различных уровней — от подключения к брокеру сообщений, к примеру, Apache Kafka, до отправки e-mail и хранения файлов.
Готовый набор коннекторов содержит «Integration Framework», где вы можете найти подходящее решение для вашей задачи.
Modeler
«Cawemo» заменил облачный «Camunda Modeler», у которого также осталось десктопная версия.
В ней по-прежнему можно создавать и редактировать модели седьмой версии, но с переносом их в восьмую могут возникнуть сложности. Официальная документация содержит инструкцию — Migrating from Camunda Platform 7 — по миграции между версиями, но не всегда это возможно. К счастью, поддержка седьмой версии останется на ближайшие 5 лет.
Другие изменения
Да, этот материал преимущественно для аналитиков, но всё же полезно знать и о других важных изменениях. Коротко затронем основные.
Платформа в новой версии разворачивается отдельно. Встраивать движок в приложение через «Springboot» теперь нельзя. Бизнес-процесс и «Workers» разделены. «Workers» интегрируются через коннекторы.
В «Camunda Automate» вошли «Zeebe» (заменил «Engine»), «Tasklist» и «Operate», который заменил «Cockpit».
«Zeebe» теперь обеспечивает возможность одновременной обработки большего числа инстансов, поскольку обновленная версия платформы не содержит узкое место, которым являлась реляционная БД. Её функции выполняют «Zeebe broker» и «Zeebe gateway».
Gateway содержит информацию о «Workers» и знает, какие таски они могут выполнять. Таски привязываются к воркерам через тот самый атрибут type, о которым я упоминал выше. Это также обеспечивает переиспользование воркеров, достаточно указать нужное значение атрибута type. Broker выступает балансировщиком нагрузки и коммутирует инстансы и воркеры между собой. Атрибут retries при этом определяет число попыток вызова.
БД в «семёрке» представляла собой один кластер, «Zeebe» разворачивается в нескольких нодах. Все данные об инстансах хранятся в брокере, а исторические данные пишутся в «Elastic», куда обращаются «Tasklist» и «Operate». В «семёрке» они обращались в БД, что создавало дополнительную нагрузку.
Сам «Tasklist» не сильно изменился. Из интересного — в UI появилась возможность забирать данные прямо из «GraphQL».
«Operate» появился из-за перехода на «Zeebe» и необходимости взаимодействовать с «Elastic». Здесь также обновился интерфейс, который, по заверениям разработчиков, стал более удобным.
Как все это отражается на практике
Уменьшение числа доступных элементов для построения диаграмм незначительно сказывается на возможностях моделирования бизнес-процессов, но при этом размывает границу между схемами различных уровней моделирования. Иными словами, схемы становятся проще, а причин отдельно проектировать модели согласовательного и аналитического уровней — меньше.
Что происходит, когда бизнес-сторона «может в BPMN»
С одной стороны, нашей команде повезло: на одном из моих проектов заказчик предоставил большое количество схем в нотации BPMN для всего своего процесса, где полностью расписал логику, используя «всю мощь» BPMN.
С другой — большое количество символов, обилие переходов между тасками, зачастую без шлюзов, использование большей части доступных символов событий и развитие процесса во всех возможных направлениях поначалу просто сбивали с толку.
Перед нами встала задача не только переделать схемы под обновленную версию Camunda, но и привести их в порядок, сохранив всю заложенную логику. Каким образом?
События и ссылки мы заменили сообщениями. Комплексные шлюзы — совокупным использованием параллельных и исключающих. В итоге совместными усилиями нам удалось достаточно быстро оптимизировать все процессы. Отсутствие части элементов нотации никак не помешало, напротив облегчило восприятие получившихся схем. В своей работы мы в основном полагались на официальную документацию — Overview Components | Camunda Platform 8 Docs.
Заключение
Новая версия Camunda, может и ограничивает «всю мощь» BPMN, но взамен предлагает не меньшее могущество. При этом новый «Modeler» становится ещё более приспособленным, гибким для работы бизнес-аналитика, дает ему всё меньше поводов заглядывать «под капот».
Может сложиться впечатление, что обновление — своего рода попытка вовсе исключить из процесса разработки продукта аналитика как единицу. Но наша деятельность не ограничивается только моделированием диаграмм :).
Обновление мажорной версии в большей степени направлено на повышение производительности платформы. При этом оно также способствует ускорению описания и согласования бизнес-процессов с заказчиком и облегчает взаимодействие с разработчиками. У последних становится меньше поводов возвращать схемы на доработку, а сэкономленное время всегда можно потратить на другие задачи проекта.
Вот таким стало мое знакомство с обновленной версией платформы Camunda. По мере накопления опыта и набора критической массы, я продолжу знакомить вас с тонкостями работы аналитика с этим инструментом, а пока — делитесь собственными результатами и задавайте вопросы в комментариях :).