How to Model Business Rules?

Today, when you design a modern business application, you have to deal more and more with constantly changing business rules. The reason for this is that not only the software industry follows the agile path. Business processes are also subject to a permanent change. At the same time, however, business processes are becoming increasingly complex as more and more information is influencing our business world. In the following I will show how business processes and their rules can be modeled with the help of BPMN.

BPMN 2.0 and Event Based Workflows

The ‘Business Process Model and Notation’ – BPMN 2.0 is the common standard to describe a business process. BPMN was initially designed to describe a business process without all the technical details of a software system. As an result, BPMN diagrams are easy to understand and a good starting point to talk about a business process with technician as also with management people. The Eclipse BPMN2 Modeler provides a graphical modeling tool for authoring business processes based on BPMN 2.0. One advantage of BPMN models is that they can also be executed by a workflow engine. With this approach it is possible to model complex business logic which previously has been hard coded.

BPMN engines basically supporting two modeling approaches – a task-oriented and an event-oriented one. A task-oriented workflow engine typically executes each task immediately, sequentially or in parallel and returns the result. Implementations of this kind of engines are for example JBPM or Activiti. In contrast to this approach, an event-oriented workflow engine manages the state of a business process and waits for events to be executed. This second approach is typically for human-centric workflow engines like Imixs-Workflow. In the following, I will show some examples how to model a business process with complex business rules based on the event-oriented approach.

Take a look at the first example:

This is a typical human-centric business process. After a new ticket workflow was started, the actor (e.g. a support-agent) decides if the ticket can be accepted or is invalid. The workflow engine waits in the status ‘New Ticket’ until one of the events is fired. The exclusive gateway after the initial task is a so called ‘Event-Gateway’ with two exclusive events.

Events can also be concatenated to cause a sequential execution of different events. For example to send an e-mail after a new task was submitted:

 

This is called a follow-up event. The workflow engine will automatically fire the event “Send E-Mail” after a new ticket was submitted. We will shortly see how these events can be used to execute different business rules.

Conditional Events

Now lets talk about more complex situations and how to model them. As I have already indicated in the beginning, business processes are often influenced by what information is available. Let us assume that an event triggers different tasks depending on the information which is available in the business task. In this situations conditional events can be used:

In this example a exclusive gateway is placed after the ‘Submit’ event. The gateway has two conditional sequence flows (SL=1 and SL=2). Conditions can be declared within the model:

So the business logic is now part of our model and can be easily changed and adapted if the business rules will change.

Split Events

Another situation is the need to split a task so it can be processed in parallel by different actors. In BPMN we use an inclusive gateway to start processing in parallel. The workflow engine creates a copy of the running process instance. Both instances are running still in the same model but can be processed by different actors or manage business data in different ways. A situation where this modeling approach is often used is to duplicate or archive business data. See the following example:

In this example, when a new “Offer” was rejected, the current version of the process instance will be archived and a new version will be continued in a change process.

Of course, this variant can also be combined with other variants. Take a look at the following example which combines a conditional event with a split event:

 

In this example the ticket with ServiceLevel=1 will be split into a ‘Medium Ticket’ and a “Reporting” task. Both instances are running still in the same model but can be processed in different ways.

Working with Different Business Models

The business logic we have modeled so far was restricted to one workflow model. But it is of course also possible to start new process instances in another workflow model. This is called a sub-process which is triggered by the main process but runs in a independent workflow model. See the next example:

In this example a ‘Sales’ process provides the management of customer data. In case a new customer data was submitted, the model tests if a offer is available. If yes a new sub-process “Order” is triggered. This process runs in a completely independent workflow model. But the workflow engine is aware of the ‘parent-child’ relation ship which allows the sub process to interact with the parent process. For example the submit event of the ‘Order’ process can send business data back to the ‘Sales’ process.

The creation of a sub-process is bound to the event ‘submit order’:

This is a powerful function to control and link different processes.

Conclusion

After this brief insight into the possibilities of modeling business logic with the help of BPMN 2.0, it becomes clear what advantages result from this. First of all, the business logic becomes more transparent because now business rules become visible and understandable. Secondly, business rules can be changed without having to change the source code of the application. This is an important factor to be able to react quickly to changes in an agile environment. In addition to these obvious advantages, BPMN also makes it possible to design very complex business rules and process flows which can be executed by a workflow engine. It may take some time to familiarize yourself with those concepts, but the benefits of creating a modern and flexible business application are worth the effort. The open source project ‘Imixs-Workflow‘, which provides a free event-orientated workflow engine, provides additional information and more examples.