As part of the preparation of the BPMN course, I will expand some videos into articles for better understanding by the listeners. You can see the video tutorial at the end of the article.
The concept of a token in BPMN raises many questions, although in fact, this essence is extremely simple and useful. Let’s start with a classic definition:
A token is a theoretical concept that is used to understand the behavior of the process in question. The behavior of process elements can be understood through how they interact with a token that moves through the process structure. Meanwhile, in runtime and modeling systems using the BPMN standard, it is not necessary to indicate a token in any form.
Simply put, a token is an entity that was introduced to control the work of a business process, debug and test it. So, in programming for such purposes, there is a step-by-step execution of the algorithm (debug mode). The programmer at any time understands at what stage the program is being executed, can track under what conditions this or that branch is turned on.
BPMN introduced a token for similar purposes. Those. it is essentially a mark that shows you which block of the process is currently being executed. By moving the token through the process, you can clearly track what will work in reality and how.
In order to work with a token, you must have the business process itself. Without it, the very concept of a token loses its meaning. Let’s take a look at what a token is and how to work with it.
Example No. 1
Consider the process of purchasing a product (see the figure below). As you can see, it is quite simple, therefore we will not describe the process itself in detail, but will focus on the token.
At the very beginning of the execution of the process, the token is at the entry point. Next, we start moving it. The token can only move sequentially, moving from stage to stage of the process.
Thus, the token goes to the stage “Create a document Purchase order”. After the successful completion of the stage, the token moves to the stage “Send an application for approval”, etc.
If we did not have such an element as a token, we would not be able to understand where the process is now.
Any process starts sequentially. It is not performed all at once, but only at a certain point. It can be a task, gateway, or event. But it is important to understand that not all processes are started, not all gateways are processed, not all tasks are completed.
At any given time, only the element on which the token is located is executed. Moreover, only the one that is necessary according to the logic of the process.
In our case, after the gateway “Application approved?” the answer is “Yes”. And the token moves along the corresponding branch. The end of the work is the exit point.
Example No. 2
For a better understanding, consider the same process. But this time, after the gateway, we got the answer “No”.
In this case, the token moves along a different thread, or, in other words, along a different thread of our process.
It is important to understand that the token “does not know” that we have some other tasks. The process, i.e. the token after the gateway followed the “no” flow path. Accordingly, everything related to the “yes” branch, in this case, is of no interest to us or to the process that is running. Thus, those branches that are not involved here and now do not exist for the process.
Example No. 3
When working with a business process, there can be several tokens, for example, if two or more branches of the process are running in parallel. Let’s consider an example of the “Purchase approval” business process.
Here we will also not dwell on the process itself. The main elements are clear from the graphical model, and details are not needed in this case. Pay attention to the stage “Approve the application”. After it, there is a parallel gateway on the diagram. This element includes two streams at the same time.
See how this is portrayed with tokens. One token moves at the entry point and up to and including the parallel gateway. Next, we need to execute two parallel processes. As a result, one token is split into two, which are executed simultaneously.
Let’s sum up
As you can see, in fact, a token is simple, understandable and convenient. Using this essence will help you always be clear about how your process works, even if it is comparatively complex. Use tokens after creating a graphical model for self-testing. Use them in demo to better understand the essence of your sentences. We will definitely talk about other useful elements of BPMN in the following publications.