BPMN in Action: Process Communication via a Message Queue

In the last post I have shown how a process running on a process engine can communicate with a second process that is installed on a different process engine. For the communication, the REST interface of the second process engine was used. Since there isn’t any standard for process engines‘ REST interfaces, the calls must be adapted to the specifics of the second engine’s interface.

A more flexible approach is the use of a message queue (MQ). Such a message queue ist provided by a message broker. The involved processes communicate by inserting and removing messages from a queue. With this approach it is easier to exchange one of the process engines with a different engine. It is even possible that a process communicates with an entirely different system, such as an ERP system. For this example, a small Java class has been written that is used as a replacement for the second process.

Download

The following zip file contains the Bonita project file, the RabbitMQ-connector, and the Java client.

Prerequisites:

Introduction

RabbitMQ:

  • If you have Docker installed you can start the installation in the command line using the following instruction:
docker pull rabbitmq
  • Then the RabbitMQ-Server can be started:
docker run -d --hostname my-rabbit --name some-rabbit -p 15672:15672 -p 5672:5672 rabbitmq:3-management
  • For installing und running RabbitMQ without Docker follow the instructions at https://www.rabbitmq.com/download.html.
  • When the installation has been successful and the server has been started, you can open the RabbitMQ management console in a browser using the address http://localhost:15672/ (username „guest“, password „guest).

Bonita:

  • Import bos file in Bonita into a new project.
  • In „Organization“: Deploy „BPMCO.organization“ (default user: admin).
  • Deploy business data model.
  • In „Process diagrams“ deploy the diagram „Collaboration – Request and Order MQ“.
  • It is possible to deploy the diagram „Collaboration – Process Request and Order MQ“ also locally. In this case, all processes are executed by the same process engine, but the communication is handled via the message queue. This scenario is not really useful, since you could simply use message flow within the process engine. However, it can be used for experimenting and testing the MQ-based communication.
  • For a distributed scenario, the diagram „Collaboration – Process Request and Order MQ“ should not be deployed locally.
  • Instead, import the bos-file into a different Bonita installation on another computer.
  • In the remote Bonita system, also deploy the organization „BPMCO.organization“ and the business data model
  • In the remote system the adress of the RabbitMQ host must be changed from „localhost“ to the actual address of the local machine. Select the pool „Forward Quotation to MQ“. In the configuration („configure“ in the upper toolbar) select „Parameters“ and change the value from „localhost“ to the actual address of your local machine.
  • Repeat these steps for the process „Retrieve Messages from MQ“
  • On the local machine, login to the portal and select „Bonita User Application“.
  • Any user can start the process. The user „admin“ can perfom all process roles, so that you don’t need to switch between different users.
  • The default password for all users is „bpm“.

Java-Client

  • Instead of the process in the remote system, you can also use the Java client.
  • In this case, the process „Retrieve Messages from MQ“ shouldn’t run, because otherwise the process and the java client would both try to fetch the same messages from the queue.
  • Copy the file proposalProcessClient.jar into a folder on the local machine and start it usingthe following instruction (requires an installation of java 16 and above):
java -jar proposalProcessClient.jar
  • If you want to modify the java client, you find the source code and the required libraries in the archive proposalProcessClient-java-src.zip.

RabbitMQ-Connector

  • The RabbitMQ connector file „connector-rabbitmq-0.0.1-SNAPSHOT.jar“ is only required if you want to use the connector in another Bonita project. The project in the bos file already contains the connector.