How to get started with BPM Platform
Tags: camunda, beginners, workflowengine
Published: 2022-02-01 07:42:48

If you want to understand how bpm workflow engine works and start writing your own workflows for any business use case, you are in the right place. At the end of this article, you will be able to have your own environment setup for workflow engine and sample BPMN.

Let’s get started!

## What is BPM engine?

BPM or process workflow engine is a engine wherein we can orchestrate the set of tasks.

It provides BPMN (Business Process Management and Notation) which can be embedded in Java applications and with other languages via REST.
BPMN is visual modelling language for Business analysis applications. Using this, we can define our workflows in much more readable way.

In this article, we will be using BPM engine offered by Camunda.

## Software requirements


1. Camunda modeler:
        https://camunda.com/download/modeler/
2. Camunda platform:
       There are different distributions for various application 
   servers. In this tutorial, we will use Spring boot project 
   distribution. 
       https://start.camunda.com/
   In above link, Click on Generate project and the zip file for 
   simple Spring boot application will be downloaded. This can be 
   imported into any IDE (ex. Eclipse, IntelliJ).

  In src/main/resources path, there will be sample process.bpmn 
  file. All the bpmn files we create must be placed in this path.

Now that our environment setup is ready, Let’s learn how to draw BPMN. 

## Some basic notations

Using Camunda modeler, we can draw BPMN and deploy the same in Camunda engine.

- Start event:
      This is used to specify the start of the process. Any pre 
      activities can be done here.
     ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7or4xqebvwt333ndhopk.png)

- Script task:
     This is used for writing any business logic or checks in the 
     BPMN internally.
	For ex. Basic condition check or validations. Script 
     format can be Groovy, JavaScript, or Python.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pp8mnbpahn2xo74dho7h.png)

- Service task:
      This is used when we want to define the logic externally and 
      make a call from BPMN to plug in the logic. It provides 
      different implementation options like Java Class, 
      Expression, Connector etc. Using connector, we can integrate 
      rest calls to external or internal APIs. 
 
 ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f2gzw9cvervuwl42i2rr.png)

- Sequence flow:
     This is used to denote the sequence in which process must 
     proceed. 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xw82vzjn2tsj1ztolydf.png)

- Exclusive gateway:
     As name suggests, this is used for deciding the sequence 
     based on the certain condition. 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4tlr73oc48ul9kkj8x21.png)

- End event:
     This is used to specify the end of the process. 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/emmyyf75pi9gzwzn9y6v.png)

Using all the notations we learned above, lets draw a BPMN for below use case.

## Use case

Booking flight ticket for given source and destination. 

Below could be the BPMN process for achieving the use case. 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5a4uunsoxfayrrsgd56a.png)
 
 
 
 Here, T1 is the task to check the ticket availability and we have Exclusive gateway to determine the flow based on the result of T1. If ticket is available, we proceed to T2 or else we proceed with T5.
After T2, again there is the Exclusive gateway which will decide the sequence based on results of T2. If Book ticket task is success, proceed to T3 or else T4.

Arrows in between the tasks denotes the sequence. Note that, these arrows can be drawn in reverse as well. Wherever the arrow points will decide the flow. So, to proceed from T1 to T2, arrow must be drawn from T1 to T2 not vice versa. 

By deploying above BPMN with all logics and API integration in the Camunda engine, we can test all possible scenarios. Debugging can be done easily via the GUI provided by Camunda engine. Camunda GUI offers Cockpit which can be used to debug the process if it gets failed.

This is very simple use case with basic notations used.
Camunda BPM provides much more notations to serve complex use cases. 


Hope you understood some basics of Camunda and BPMN in this article. Let’s see how to create Rest API and integrate it with our BPMN and deploy to our Engine in the next article.

## Few buzz words

<u>Process</u>:  In BPM engine, every workflow is called as a process and instance of the process is called process Instance. (As in Class and Object).
<u>Task</u>: Task is the activity we perform inside the process.
Sequence flow: The arrows which determines the path.
<u>Event</u>: Represented in circles, describes something that happens during process execution. (for ex. start event, end event, error event etc.,.)
<u>Gateway</u>: This is used to decide the path based on data or condition.

Happy Learning! 😊