Software Development Blogs

Software Development

Camunda

1.0 What is Camunda

Camunda is an open-source workflow and decision automation platform. It is developed in Java and released as open-source software under the terms of Apache License on August 2013. It provides a Business Process Model and Notation (BPMN) standard compliant workflow engine and a Decision Model and Notation (DMN) standard compliant decision engine, which can be embedded in Java applications and with other languages via REST.

1.1 Different Camunda Editions

  1. Camunda Community Edition
  2. Camunda Enterprise Edition

1.2 Download Camunda Server

  1. Navigate to Download URL.
  2. There are two types of Camunda distribution available to Download.
    • a) Camunda Platform Run  b) Camunda Tomcat Distribution.
  3. Download desired Camunda Distribution and unzip the file to specified location in the system.

1.3 Start Camunda Server on Windows Machine.

  1. After Unzip the file we got a camunda-bpm-run-7.15.0 folder for Camunda Platform Run and camunda-bpm-tomcat-7.15.0 folder for Camunda Tomcat Distribution.
  2. Just double click on start.bat file for Camunda platform Run or for tomcat distribution double click on start-camunda.bat file. It will start the camunda server.
  3. After that Navigate to the URL (http://localhost:8080/camunda/app/welcome/default/#!/login)

and login with default credentials demo, demo.

1.4 Start Camunda Server on Linux Machine.

  1. After Unzip the file we got a camunda-bpm-run-7.15.0 folder for Camunda Platform Run and camunda-bpm-tomcat-7.15.0 folder for Camunda Tomcat Distribution.
  2. Just type below command to start the Camunda server.
for Camunda Platform Run
sh start.sh

for Camunda Tomcat Distribution
sh start-camunda.sh

1.5 Change Camunda Server port.

By default Camunda Server Run on 8080 port. But sometimes 8080 port is already occupied by some other process. In that case we need to change our Camunda server port.

Change Camunda Server Port for Camunda Platform Run Distribution.                 

  1. After Unzip Camunda zip file just change Directory to camunda-bpm-run-7.15.0\configuration
  2. Just open the default.yml file.  Place server.port :8090 tag before camunda.bpm tag and replace 8090 with desired port no.
  3. Then Restart Camunda Server by closing the cmd window opened during server start up time and start server again by double click on start.bat file inside the camunda-bpm-run-7.15.0  folder.   
  • Make sure given port number must be free to start Camunda server.

1.6 Change Camunda Server Port for Camunda Tomcat Distribution.

  1. After Unzip the zip file just change directory to camunda-bpm-tomcat-7.15.0\server\apache-tomcat-9.0.43\conf\
  2. Inside the conf folder open server.xml file and search for below text.

<Connector port=”8080” Just change 8080 with desired port and restart the Camunda server by double click on shutdown-camunda.bat inside the camunda-bpm-tomcat-7.15.0 folder and then start again by double click on start-camunda.bat file.

1.7 Different Components of Camunda

  1. Camunda Modeler
  2. Camunda Server
  3. Cockpit App
  4. Task List App
  5. Admin App

1.8 Why Camunda

  1. Automate business processes from end to end.
  2. Build automated decisions into business processes.
  3. Get lightning-fast process execution.
  4. Ensure high availability for business.
  5. Integrate with your technology stack.

1.9 What is DMN (Decision Model and Notation)

  1. It is a table like structure which contains a set of inputs and output corresponding to inputs.
  2. DMN is a standard given by Object Management Group.
  3. It visually represents Business Decisions in a process.

2.0 Advantages of DMN

  1. Help to reduce multiple if else condition in code. 
  2. Provide a tabular form to write business rules.
  3. Easy for business analyst to define business rules.
  4. Support Friendly Enough Expression Language.

2.1 Evaluate a DMN using Rest.

POST http://{IP}:{Port}/engine-rest/decision-definition/{id}/evaluate

POST http://{IP}:{Port}/engine-rest/decision-definition/key/{key}/evaluate

Request Payload 
{
  "variables" : {
    "season" : { "value" : "Fall", "type" : "String" },
    "guestCount" : { "value" : 7, "type" : "Integer" }
  }
}
Response
[
  {
    "dish": { "value" : "Fish Curry", "type" : "String", "valueInfo" : null }
  }
]

2.2 What is FEEL (Friendly Enough Expression Language )

FEEL is an Expression Language, used by Camunda DMN Engine to evaluate input expressions given in DMN Table. FEEL is a term for input expressions given in DMN table, are simple unary tests. These unary tests test an input value against an expression and either return true if the test is passed and false otherwise.

2.3 Different Data Types Supported by FEEL

  1. Numeric (including  integer, long and double)
  2. String
  3. Boolean
  4. Date-Time

2.4 Different Elements of FEEL are:

  1. Comparison: Different Comparison operators are given in Below Table.
NameOperatorExampleDescription
Equal“Provider”Test that the input value is equal to the given value.
Less< 10Test that the input value is less than the given value.
Less or Equal<=<= 10Test that the input value is less than or equal to the given value.
Greater> 10Test that the input value is greater than the given value.
Greater or Equal>=>= 10Test that the input value is greater than or equal to the given value.

2. Range

Some of the FEEL Data Types Including Numeric and Date can be tested against a given range of values. A range consist of a start value and an end value. Different Range operators to include and exclude start and end range are given in below table.

StartEndExampleDescription
IncludeInclude[1..10]Test that the input value is greater than or equal to the start value and less than or equal to the end value.
ExcludeInclude]1..10] or (1..10]Test that the input value is greater than the start value and less than or equal to the end value.
IncludeExclude[1..10[ or [1..10)Test that the input value is greater than or equal to the start value and less than the end value.
ExcludeExclude]1..10[ or (1..10)Test that the input value is greater than the start value and less than the end value.

3. Disjunction

A disjunction is a combination of two or more statements formed by joining two or more statements with the help of OR Operator. A Disjunction operation can either have comparisons and ranges. Test returns true if one of the condition is true at a time otherwise it return false if all the conditions in a Disjunction expression are false.

Examples:

2,15,71: Test if the input is either 2, 15 or 71

<5,>10: Test if the input is either less than 5 or greater than 10

1,[14..30]: Test if the input is either 1 or between 14 and 30

“Apple”,”Samsung”,”Redmi”: Test if the input is either the String Apple, Samsung or Redmi.

4. Negation

Negation means invert the output of a Boolean expression given in DMN Table. In Feel a unary test can be negated with not operator. A Negation can work on a Single expression, range and comparisons. It can’t be used with a combination of Disjunction expression.

Examples

not(“Provider”): Test if the input is not the String Provider

not(>10): Test if the input is not greater than 10, which means it is less than or equal to 10

not(3,5,7): Test if the input is neither 3, 5 nor 7

not([20..30]): Test if the input is not between 20 and 30

not([0..17]),>0 can’t use Negation with combination of Disjunction Expression.

5. Date Functions

Camunda DMN Engine support below date function to convert a String to Date and Time.

date and time(“…”): Creates a date and time value from a String with the format yyyy-MM-dd’T’HH:mm:ss

Examples:

date and time(“2015-11-30T12:00:00”): Test if the input is the date November 30th, 2015 at 12:00:00 o’clock

2.5 DMN Hit Policy

A decision table has a hit policy that specifies what should be the results of the evaluation of a decision table consist of. The hit policy is set in the hitPolicy attribute on the decisionTable XML element. If no hit policy is set in the hitPolicy attribute of decision table, then the default hit policy Unique is used.

 Types of Hit Policies

  1. Unique Hit Policy : According to this policy only a single rule can be satisfied at a time or no rule at all. The decision table result contains the output entries of the satisfied rule. If more than one rule is satisfied, the Unique hit policy is violated.

2. First Hit Policy : We can satisfy multiple rules with the given input in DMN Table. But according to this policy decision result contains the output of the first satisfied rule.

3. Rule Order Hit Policy : This Policy says that Decision table result contains the output of all the satisfied rules in the order in which rules are defined in DMN Table. 

4. Collect Hit Policy : This policy is very similar to rule order policy, the only difference is that it contains the output of all satisfied rules in an arbitrary order.

2.6 Aggregators in Collect Hit Policy

Collect hit policy can be used with aggregators. If an aggregator is used with collection hit policy then it returns only a single result based on the aggregator used. There are four types of aggregators supported by Camunda  DMN Engine.

  1. Sum Aggregator: This Aggregator can be used to sum up all the outputs from the satisfied rules. Sum aggregator can only be applied if the output column datatype is numeric. It can be used with range, negation and Disjunction expression.

2. Min Aggregator: Min Aggregator is used to find the minimum output value from all the satisfied rules. It can be used with Negation, Range and Disjunction. Also the datatype of output column should be numeric.

3. Max Aggregator: Max Aggregator is used to find the maximum output value from the all satisfied rules. It can be used with Negation, Range and Disjunction. Also the datatype of output column should be numeric. 

4. Count Aggregator: Count Aggregator is used to  get the count of all the satisfied rules. The datatype of the output column can be any from all the supported datatypes. It can be used with negation, range and disjunction expression.

References: 1. https://camunda.com 2. https://docs.camunda.org

One thought on “Camunda”

Leave a Reply