Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to deploy a workflow engine

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article introduces the relevant knowledge of "how to deploy workflow engine". In the operation process of actual cases, many people will encounter such difficulties. Next, let Xiaobian lead you to learn how to deal with these situations. I hope you can read carefully and learn something!

business documents

To deploy the process, it needs to be wrapped in a business document

BPMN2.0 Process

task form

rules

Any other type of file

A business document is a unit of Activiti engine deployment

A business document is equivalent to a compressed file that contains:

Business documents are containers that contain named resources

When a business document is deployed, it will automatically scan BPMN files with **.bpmn20.xml or.bpmn** extensions. Each such file will be parsed and may contain multiple process definitions

Java classes in the business archive will not be able to be added to the classpath In order for the process to run, all custom classes used by the process definitions that exist in the business archive (e.g. Java service tasks or listeners that implement events) must be programmatically deployed under the classpath of the activiti engine

Deploy business documents from one compressed file (Zip and Bar supported)

deployment can also be built from a separate resource (e.g. bpmn, xml, etc

String barFileName = "path/to/process-one.bar";ZipInputStream inputStream = new ZipInputStream(new FileInputStream(barFileName));repositoryService.createDeployment() .name("process-one.bar") .addZipInputStream(inputStream) .deploy(); deployed via Activiti Explorer console

Activiti web console allows you to upload a compressed file in bar format (or a file in bpmn20.xml format) via the web interface user interface. Select the Management tab and click Deployment:

external resources

Process definitions are stored in Activiti supported databases

When using a service task, execute a listener

Process definitions can refer to these delegate classes when configured from Spring beans in Activiti configuration files.

These classes or Spring configuration files must be available for all process definitions that may be executed in the process engine

Java class

When a process instance is started, all custom classes used in the process should exist under the classpath of the process engine:

JavaDelegates

event listener

task listener

In service tasks:

These classes do not all have to exist under the classpath when deploying business documents. When deploying a new business document using Ant, it means that your delegate classes do not have to exist under the classpath

When adding custom classes using the sample settings:

jar package containing custom classes should be added to the activity-explorer console

actiti-rest webapp lib folder

Don't ignore dependencies that contain your custom classes

You can also add your custom dependencies to ${tomcat.home}/lib in the installation directory of your Tomcat container

Use Spring beans in processes

When expressions or scripts use Spring beans, these beans must be available for the engine to execute the process definition

If you want to build a custom web application and configure the process engine according to Spring integration in the application context. Keep in mind that if you are using Activiti rest web app, then you should also update the Activiti rest web app context. You can replace activiti.cfg.xml in activiti-rest/lib/activiti-cfg.jar file with activiti-context.xml file for Spring context configuration

Create standalone apps

Activiti rest web applications can be added to web applications by configuring a ProcessEngine,

This eliminates the need to ensure that all delegate classes of all process engines are under the classpath and that the correct spring configuration is used

Version of process definition

There is no concept of version in BPMN, whereas in Activiti, the version of the process definition is created at deployment time, and Activiti automatically assigns a version number to the process definition at deployment time before it is stored in the database used by Activiti.

For each process definition in the business document, the initialization attributes key,version,name, and id are executed through the following deployments:

The id attribute of the process definition (process model) in the XML file is treated as the key attribute of the process definition

The name attribute of the process model in the XML file is treated as the name attribute of the process definition. If the name attribute is not specified, the id attribute is treated as if it were the name attribute.

A process definition with a specific key will automatically be assigned a version number of 1 when deployed for the first time, and the version number of subsequent deployments with the same key will be set to a value 1 greater than the current maximum version number. The key attribute is used to distinguish between different process definitions

The id attribute in the process definition is set to {processDefinitionKey}:{processDefinitionVersion}:{generated-id}, where generated-id is a unique number added to ensure the uniqueness of the process definition cached in the cluster environment

...

When this process definition is deployed, the process definition in the database is as follows:| id| key| name| version||--|--|--|--||myProcess:1:676| myProcess| My important process| 1|

Suppose the deployment uses the latest version number of a process (change user task), but the ID of the process definition remains unchanged. The process definition table will contain the following list information:

idkeynameversionmyProcess:1:676myProcessMy important process1myProcess:2:870myProcessMy important process2 When the runtimeService.startProcessInstanceByKey("myProcess") method is called, it will use the process definition version number 2 because this is the latest version of the process definition. It can be said that each time a process definition creates a process instance, the latest version of the process definition is used by default

Create a second process, define and deploy it in Activiti, and add the process definition to the process definition table:

...

The table structure is as follows:

idkeynameversionmyProcess:1:676myProcessMy important process1myProcess:2:870myProcessMy important process2myNewProcess:1:1033myNewProcessMy important process1

Note: The key of the new process is different from our first process, although the process definition name is the same (of course, the name can also be different),Activiti only considers the id attribute to determine the process. Therefore, the new process definition deployment has version number 1

Provide process pictures

Flowcharts for process definitions can be added to the deployment, persisted to the database used by Activiti and accessible through Activiti's API.

Flowcharts can also be used to display processes in the Activiti Explorer console

If we have a process under our classpath: org/activiti/expenseProcess.bpmn20.xml, the process definition has a process key=expense. The following follow the naming convention for flow-defining images (in this particular order):

It should be org/activiti/expenseProcess.png. Note: This means that every process definition in the same BPMN2.0 XML folder will have the same process definition image. Therefore, there is only one process definition in each BPMN 2.0 XML folder, which is absolutely no problem

org/activiti/expenseProcess.expense.png (or jpg/gif). This makes more sense if you define multiple process definition images in a BPMN 2.0 XML file. Each process definition image will have a process definition key in its filename

If an image resource already exists at deployment time, it is the XML file name of BPMN 2.0 followed by the key of the process definition and a suffix for an image. Then the picture will be used.

If no such image exists, deploy looking for image resources with names matching BPMN 2.0 XML files

Use programmatic deployment:

repositoryService.createDeployment() .name("expense-process.bar") .addClasspathResource("org/activiti/expenseProcess.bpmn20.xml") .addClasspathResource("org/activiti/expenseProcess.png") .deploy();

Next, you can get the process definition image resource through the API:

ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery() .processDefinitionKey("expense") .singleResult(); String diagramResourceName = processDefinition.getDiagramResourceName(); InputStream imageStream = repositoryService.getResourceAsStream(processDefinition.getDeploymentId(), diagramResourceName); Automatically generate process pictures

In the case of deployment where no image is provided,Activiti process engine automatically generates an image if the process definition contains the necessary 'image exchange' information

This resource can be obtained in exactly the same way as the process image provided for deployment above:

If, for some reason, it is not necessary or necessary to generate a process definition picture during deployment, you need to configure it using isCreateDiagramOnDeploy in the process engine configuration properties to avoid generating a process definition picture:

category

Deployment and process definitions are user-defined categories

Initialized values of attributes in the BPMN file for process definition categories:

Deployment categories can be specified directly using the API:

repositoryService .createDeployment() .category("yourCategory") ... .deploy();"How to deploy workflow engine" content introduced here, thank you for reading. If you want to know more about industry-related knowledge, you can pay attention to the website. Xiaobian will output more high-quality practical articles for everyone!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report