In the era of saas craze, workflow seems to be a professional quality

Keywords: Java IntelliJ IDEA intellij-idea


  • Now more and more projects begin to use workflow to meet their daily work. Today, let's take a look at the workflow of Activiti. Let's start with BPMN painting

Environment installation

  • BPMN documents about processes are mainly integrated through eclipse development tools. The idea is mainly painted by actiBPM, but actiBPM is no longer maintained after 2014. Now it can not be directly installed and used in the new idea version.
  • In that case, you can develop an idea project and draw it through eclipse, but this situation seems troublesome. Here we recommend another integration tool to draw BPMN process diagram
  • Camunda modeler is a third-party process design tool. Its advantage is that instead of eclipse, we can load it through the External Tools of idea.

  • His configuration is also very simple

  • We can draw the rest.


  • Most of the third-party process drawing software similar to camunda will be provided to the community office. They are started as java services. Why do you need this way? Because in this way, we can draw the process through camunda by calling the api. It can be drawn in our own process platform. In this way, the process plotter is connected to our own platform system.

Release process

  • First, we draw a simple process through camunda. Above, we first launch a camunda platform in the form of tomcat to release our production process.

Service task

  • First of all, the action of swiping card for payment is a server operation. Here, we click the settings bar on the right to set the server service mode

  • Finally, the server obtains node information by listening, so we need to set the message type (Topic).


  • Now our process is still very simple. Above, we set the Implementation method to External, which means that the node is jointly implemented with the help of External services and specifies the message subject topic. For message listening, we monitor the information in Java. Another important role in the process is the gateway. The gateway here is our judgment node. For example, there is a demand for credit card payment requests above
  • Payment approval is required when the payment amount is greater than or equal to 1000 yuan. If it is less than 1000 yuan, payment can be made directly.
  • There is one in camunda × The graph of is what we call gateway. Let's modify the flow chart a little

  • We can drag the gateway directly. Its feature is that there are two or more branches. So which branch will go eventually requires us to set conditions on each branch. Here we set the conditions through Java expressions.

  • amount this is a variable. You can define this variable at will, but it must be provided at the beginning of the process, otherwise an error will be reported

  • We can ask the user to provide the necessary information of the process before the gateway starts

  • Then the process will be reversed according to the amount filled in. Payment approval needs to be approved according to the process information, so I also added the item parameter to fill in the application form. Why add this parameter? If I am the person in charge of approving payment. But I don't care much about the amount of money, or I have no brain to pass some projects. At this time, we can realize the automatic approval of this node with the help of the automatic decision-making of the process.
  • Here we introduce the DMN of the process. We create a new DMN file through camunda. And set the id of the DMN

  • Then click the icon in the upper left corner to set the rules

  • Our rules are very simple. I will approve any item XYZ project, otherwise it will not be approved.

  • In this rule, we can set many ways, and our above is the only way, that is, each condition is mutually exclusive, either black or white. There are other ways we can debug ourselves

  • In returning to our main process, we select the Implementation method as DMN, and ref select the id of the DMN we set above

Java monitoring process information

Copy code
  • After we add dependencies here, we start listening to the external services in the process corresponding to the topic of our process
ExternalTaskClient client = ExternalTaskClient.create()
        .asyncResponseTimeout(10000) // Long polling timeout

// Subscribe to the specified external task
        .lockDuration(1000) // The default locking time is 20 seconds, which is modified to 1 second here
        .handler((externalTask, externalTaskService) -> {
            // Write your business logic here

            // Get process variables
            String item = (String) externalTask.getVariable("item");
            Long amount = (Long) externalTask.getVariable("amount");

  "Charging credit card with an amount of '" + amount + "'€ for the item '" + item + "'...");

            try {
                Desktop.getDesktop().browse(new URI(""));
            } catch (Exception e) {

            // Complete the task
Copy code
  • Now we can check the log,

Maltcloud integration

  • Workflow is scheduled in phase II in the maltcloud version plan, so I plan to develop workflow related operations after the basic functions of maltcloud are completed. The first is process drawing. The basic drawing and publishing of process have been mentioned above. Let's take a look at how to inherit workflow into our enterprise framework maltcloud.
  • Note that the springboot and camunda versions need to match during integration. The official website provides us with a matching scheme for the response version

  • Here's an explanation
    • The first column [springboot starter version] represents the springboot starter version of camunda.
    • The second column [camunda platform version] represents the actual camunda version
    • The third column [springboot version] represents the springboot version of our system.
  • The version 2.2.2.RELEASE is used in combination with maltcloud. We can locate that the version of camunda springboot starter should be 3.4.x; Then we go to maven warehouse to check the relevant versions

  • Here I chose to use version 3.4.0 at the beginning. Later, it was found that the springboot of 2.2.x.RELEASE also supports 7.13.x. finally, it was decided to use 7.13.0.

  • Because mybatis used in camunda BPM spring starter uses version 3.5.3, but maltcloud uses version 3.5.6. So I still need to solve the conflict here. The final pom configuration is as follows

Copy code
  • Maltcloud is an enterprise level development framework designed by the author. It is still in the development stage for the time being and will be open source in the appropriate period. Here I introduce the datasource module in the maltcloud platform. This module mainly introduces the configuration of mybatis. Readers can remove this paragraph and configure mybatis by themselves.

Detail supplement

Related version documents

  • Select the version through options. You can download the specified version in the Installation Procedure. After clicking in, there will be a list of small versions. Because we chose 7.13.0 in maltcloud. So we download the corresponding platform camunda

Posted by mechew on Fri, 12 Nov 2021 01:16:00 -0800