workflow

Workflow Introduction

  • Workflow (Workflow) :Workflow is to automate the management of business processes through computer technology. Implement multiple participants to automatically execute a business process according to a predetermined process.
    • Definition: Automate management of business processes by computer
    • The main solution is to automate the transfer of documents, information, or tasks between multiple participants according to some predefined rules. To achieve or facilitate the achievement of a desired business goal
  • Objectives of workflow management system:
    • Manage the flow of work to ensure that work is performed at the right time by the desired personnel
    • Inserting human execution and intervention into automated business processes
  • Workflow framework:
    • Activiti,JBPM,OSWorkFlow,WorkFlow
    • Workflow framework needs to be supported by a database

Workflow terminology

Workflow engine
  • ProcessEngine object: This is the heart of Activiti’s work. Responsible for generating various instances and data of process running time, monitoring and managing process running
BPM
  • Business process Management:
    • It is a systematic approach to continuously improve an organization’s business performance centered on the standardized construction of end-to-end business process excellence
    • Common business management education, such as EMBA and MBA, includes BPM
BPMN
  • Business process modeling and annotation:
    • How these diagrams are put together into a Business Process Diagram
    • Discuss the various uses of BPMN, including the precision with which models are influenced in a flowchart
    • Value of BPMN as a standard
    • Vision of BPMN’s future development
Stream objects

A business process diagram has three core elements of flow objects

  • The event
    • An event is described as a circle, representing what happens during a business process
    • Events affect the flow of processes. There is usually a cause (trigger) or an effect (effect)
    • Based on their impact on the process, there are three types of events: start events, intermediate events, and termination events

  • activity
    • Represented by rounded rectangles, a process consists of one or more activities

  • conditions
    • Conditions, represented by diamonds, are used to control the branching and merging of sequence flows.
    • Options include branching and merging paths
    • Internal markers give the type of control flow

Activiti open source workflow framework

Introduction of Activiti

  • Activiti is an open source workflow engine that implements the BPMN 2.0 specification, publishes designed process definitions, and schedules processes through apis
  • Activiti is an apache-licensed open source platform for workflow and business process management. At its core, Activiti is an ultra-fast, ultra-stable java-based BPMN2.0 process engine that emphasizes the embedability and extensibility of process services, with a greater emphasis on business people
  • The Activiti process engine focuses on ease of use and lightweight system development. Each BPM business function, the Activiti process engine, is provided to the developer as a service. By using these services, developers can build feature-rich, lightweight and efficient BPM applications

Activiti service structure

  • Activiti System service structure diagram

  • Core classes:
    • ProcessEngine: an abstraction of the ProcessEngine through which you can get all the services you need
  • Service types:
    • XxxService:Acquired by ProcessEngine,Activiti encapsulates services with different life cycles in different services, including definition, deployment, and execution. Service classes are used to obtain service information in the related life cycle
      • ==RepositoryService==
        • The Repository Service provides access to a Repository
        • Definition files, deployment files, and supporting data (such as BPMN2.0XML files, form definition files, process definition image files, and so on) are required for each different version of the business process definition in Activiti, which are stored in Activiti’s built-in Repository
      • ==RuntimeService==
        • The Runtime Service provides the functions of starting processes, querying process instances, and setting and obtaining process instance variables. It also provides access services for process deployment, process definition, and process instances
      • ==TaskService==
        • The Task Service provides operations on user tasks and forms. It provides run-time task query, retrieve, complete, delete and variable setting functions
      • ==HistoryService==
        • The History Service is used to obtain information about running or completed process instances. Unlike process information obtained in The Runtime Service, History information contains persistent information that has been persisted and optimized for queries
      • ==FormService==
        • Use Form Services to access Form data needed to start and complete tasks and render forms as needed
        • Both process and status Tasks in Activiti can associate business-related data
      • ==IdentityService==
        • Identity Service provides the ability to manage users and groups in Activiti systems
        • Activiti has built-in user and group management functions. You must use these user and group information to retrieve tasks
      • ManagementService
        • Management Service provides Management and maintenance capabilities for the Activiti process engine
        • These features are not used in workflow-driven applications and are primarily used for routine maintenance of the Activiti system
  • Core business Objects:
    • Org. Activiti. Engine. Impl. Persistence. The entity class under the package, including Task, ProcessInstance, Execution, etc
    • The way the interfaces are implemented for different responsibilities (inherits the PersistentObject interface if persistence is required) is different from a traditional entity class

Activiti components

  • Activiti Context component Context:==It is used to save global information with a long life cycle, similar to Application. It mainly includes the following three categories:
    • CommandContext: CommandContext – saves the resources necessary for each command, such as the session required for persistence
    • ProcessEngineConfigurationImpl: process engine related configuration information – the engine of the global configuration information. For example, a DataSource DataSource. This object is a singleton and is initialized when the process engine is created
    • ExecutionContext: Holds an ExecutionEntity object
  • == Persistent component :==
    • Activiti uses MyBatis for OR mapping and has designed its own persistence framework on top of that
    • The top-level interface Session,SessionFactory is initialized when the process engine is created
    • Session has two implementation classes:
      • DbSqlSession: responsible for the execution of SQL expressions
      • AbstractManager: Takes care of persistent operations on objects
    • SessionFactory has two implementation classes:
      • DbSqlSessionFactory: Performs operations related to DbSqlSession
      • GenericManagerFactory: Responsible for AbstractManager-related operations
  • = = the Event – the Listener component: = =
    • Activiti allows client code to intervene in process execution and provides event listening components
    • Type of event to listen for:
      • TaskListener
      • JavaDelegate
      • Expression
      • ExecutionListener
      • ProcessEngineConfigurationImpl holds DelegateInterceptor an instance, convenient call handleInvocation
  • = = = = Cache components
    • DbSqlSession has cache implementation
    • Activiti caches based on lists and maps: if a query is in the cache first, it is not in the cache directly
  • == Asynchronous execution component ==
    • Activiti can perform tasks with JobExecutor as its core class. JobExecutor contains three main properties:
      • JobAcquisitionThread
      • BlockingQueue
      • ThreadPoolExecutor
      • Methods ProcessEngines in engine startup called JobExecutor. Start, JobAcquisitionThread thread started work, its run method cycle AcquiredJobs execution of the job, The thread waits until a timeout or the JobExecutor. JobWasAdded method is called because of a new task.

Process VM PVM

  • The process VIRTUAL Machine API exposes the POJO core of the process virtual machine. The process Virtual Machine API describes the essential components of a workflow process. These components include:
    • PvmProcessDefinition: The definition of the process, symbolically the diagram drawn by the user. The static meaning
    • PvmProcessInstance: Process instance, an instance of a PvmProcessDefinition that the user initiated. Dynamic meaning
    • PvmActivity: a node in the process
    • PvmTransition: A path that connects nodes. Figuratively speaking, it is the connection line between nodes in the figure
    • PvmEvent: Events triggered during process execution

Activiti framework

  • Activiti Engine:
    • The core module
    • Provides the BPMN 2.0 specification for parsing, executing, creating, managing (tasks, process instances), querying history and generating reports based on results
  • Activiti Modeler:
    • Model designer
    • Suitable for business people to translate requirements into canonical process definitions
  • Activiti Designer:
    • Similar in functionality to Activiti Modeler, it also provides visual design capabilities based on the BPMN 2.0 specification, but currently does not fully support the DEFINITION of the BPMN specification
    • You can import the process definitions (in XML format) designed by the business requirements person in Signavio into Designer, allowing the developer to further refine them into a runnable process definition
  • Activiti Explorer:
    • It can be used to manage warehouses, users, groups, startup processes, tasks, etc
    • This component uses a REST-style API to provide a basic design model. If the service is simple, it can be used without development. Can also be used as a background administrator’s process, task management system
  • Activiti REST:
    • Provide RESTful services
    • Allows clients to interact with the engine’s REST API as JSON
    • The generic protocol is cross-platform and cross-language

Activiti database support

  • Activiti is backed by a database
  • All tables begin with ACT_
  • The second part is a two-letter identifier that indicates the purpose of the table
  • The purpose also corresponds to the service API
ACT_RE_* : 'RE' for repository. This prefixed table contains process definitions and process static resources (images, rules...). ACT_RU_* : 'RU' stands for runtime. These run-time tables contain running data for process instances, tasks, variables, asynchronous tasks, etc. Activiti saves this data only during the process instance execution and deletes the records at the end of the process. This way the runtime table can always be small and fast ACT_ID_* : 'ID' stands for identity. These tables contain identity information such as users, groups... ACT_HI_* : 'HI' for history. These tables contain historical data, such as historical process instances, variables, tasks... ACT_GE_* : common data. Used in different scenarios, such as storing resource filesCopy the code
  • Repository flow rule table (ACT_RE_*:’RE’ for repository. This prefixed table contains process definitions and process static resources (images, rules…). )
Act_re_deployment Deployment information table act_RE_MODEL Process design model deployment table act_RE_procdef Process definition data tableCopy the code
  • Runtime database table (ACT_RU_*:’RU’ for Runtime. These run-time tables contain running data for process instances, tasks, variables, asynchronous tasks, and more. Activiti saves this data only during the process instance execution and deletes the records at the end of the process. So the table can always be very small and very fast.)
Act_ru_execution Run-time process execution instances ACT_ru_identitylink Run-time process personnel table, which stores information about task nodes and participants ACT_ru_TASK Run-time task node table ACT_ru_variable Runtime process variable data tableCopy the code
  • Organization table (ACT_ID_* : ‘ID’ stands for identity. These tables contain identity information such as users, groups…)
Act_id_group User group information act_ID_info User extended information act_ID_membership Information table of users and user groups act_ID_user User information table These four tables are very common. For basic organizational management, it is suggested to develop a set of user authentication by ourselves. The built-in functions of the components are too simple to meet many requirements in useCopy the code
  • History database tables (ACT_HI_*:’HI’ for history. These tables contain historical data such as historical process instances, variables, tasks…)
Act_hi_actinst Historical node table ACT_HI_Attachment Historical Attachment table act_HI_COMMENT Historical comment table act_HI_identitylink Historical process personnel table act_hi_detail Historical details table, Act_hi_procinst history process instance table ACT_hi_taskinst History task instance table ACT_hi_VARinst history change tableCopy the code
  • Organization table (ACT_GE_*: generic data. For different scenarios, such as storing resource files)
Act_ge_bytearray Binary data table ACT_GE_property Data table stores data at the process engine level. When initializes the table structure, three records are inserted by defaultCopy the code
Activiti profile
  • activiti.cfg.xml:The Activiti core configuration file that configures the basic parameters of the process engine creation tool and database connection pool parameters
    • Define database configuration parameters
    • Set connection pool parameters

Activiti characteristics

Data persistence
  • Activiti is designed with simplicity and speed in mind
  • The bottleneck is in the process of exchanging data with the database, and Activiti has chosen to enable MyBatis so that it can execute commands with optimal SQL statements, which alone can keep the engine running at maximum speed
Engine Service interface
  • The Activiti process Engine focuses on ease of use and lightness of system development. Every BPM business function Activiti process engine provides developers with services that enable them to build rich, lightweight and efficient BPM applications
  • Activiti. CFG. XML file as the core configuration files, the profile of integration in the Spring IOC container, can produce ProcessEngineConfiguration object, the object is the process engine configuration object
  • The ProcessEngine object is the ProcessEngine object, which is the core of workflow business system, and all business operations are realized by the object derived from this object
  • The Activiti engine provides seven Service interfaces, all obtained through ProcessEngine, and supports the chained API programming style
Flow designer
  • Web-based Activiti Modeler process designer
  • ActiBPM plug-in for IDEA
Native support for Spring
  • Activiti has native Spring support for easy Spring integration, making it easy to manage transactions and parse expressions
Separate runtime history data
  • Activiti inherits from jBPM4 and also follows the separation of runtime and historical data in terms of table structure design
  • This design allows the runtime data to be read quickly and only read from a dedicated historical data table when historical data needs to be queried. This design approach can greatly improve the efficiency of data access, especially when the data can be accumulated over a long period of time