Activiti development study notes

image

  1. Overview Introduction

Recently the company has a large project that needs to use the process engine platform. The service governance platform must provide process governance services, so the editor is stepping up the development of learning workflow engine. So what we are about to learn is a business process management framework, common open source workflow engine frameworks: OSWorkFlow, jBPM (jboss business process management), Activiti workflow (an upgrade to jBPM). The process development framework is generally called the workflow framework.

Why is activit recommended?

Activit is an open source, flexible, and easily extensible executable process language framework covering business process management, workflow, service collaboration and other fields. Activiti is based on the Apache-licensed open source BPM platform. The founder Tom Baeyens is the project architect of JBoss jBPM. It features an eclipse plug-in, through which developers can draw their business directly.
In addition, I think it is relatively better than JBPM: No matter how simple it is, the development difficulty is reduced.
  1. Technical Framework-Development Environment

  • Language: Java 8
  • IDE (JAVA): IDEA / Eclipse install activit plug-in
  • IDE (front end): WebStorm or IDEA
  • Dependency management: Maven
  • Database: MySQL5.7
  1. First example

Source download address, just copy and download


import org.activiti.engine.ProcessEngine;

import org.activiti.engine.ProcessEngines;

import org.activiti.engine.RepositoryService;

import org.activiti.engine.RuntimeService;

import org.activiti.engine.TaskService;

import org.activiti.engine.task.Task;


/**

 * The first process running class

 */

public class First {

public static void main(String[] args)  {

// Create process engine

ProcessEngine engine = ProcessEngines.getDefaultProcessEngine();

// Get the process storage service component

RepositoryService repositoryService = engine.getRepositoryService ();

// Get runtime service components

RuntimeService runtimeService = engine.getRuntimeService();

// Get process task component

TaskService taskService = engine.getTaskService();

// Deployment process file

repositoryService.createDeployment().addClasspathResource("bpmn/First.bpmn").deploy();

// start process

runtimeService.startProcessInstanceByKey("process1");

// Query the first task

Task task = taskService.createTaskQuery().singleResult();

System.out.println("Before the first task is completed, the current task name: "+ task.getName());

// Complete the first task

taskService.complete(task.getId());

// Query the second task

task = taskService.createTaskQuery().singleResult();

System.out.println("Before the second task is completed, the current task name: "+ task.getName());

// Complete the second task (end of process)

taskService.complete(task.getId());

task = taskService.createTaskQuery().singleResult();

System.out.println("After the process ends, find the task: "+ task);

// drop out

System.exit(0);

}

}

  1. to sum up

Summary: To use activit, first create a process engine,  get the process storage service component , get the runtime service component , deploy the process file and start the process.


This example is relatively simple, don't joke everyone.

  1. Scan QR code to follow

image

(the public)

image

(WeChat)

  1. Disclaimer

[ Writing instructions ] The above content is shared with programmers who like to program and have dreams, and hope to help you. The above article belongs to the original public account. If you need to reprint, please indicate the source.

[ Disclaimer ] This public platform is not an advertiser, nor does it advertise for other third-party websites or individuals. The source code and articles shared here are some of the projects that I think are good in the project and study. Some voluntary download or payment behaviors generated by users. Not directly related to the platform

Submission Email[email protected]

 Contributions are welcome to share your high-quality source code or articles


Guess you like

Origin blog.51cto.com/15067267/2576604