In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
The editor today takes you to understand the flowable workflow engine migration API instance analysis, the knowledge points in the article are introduced in great detail. Friends who feel helpful can browse the content of the article together with the editor, hoping to help more friends who want to solve this problem to find the answer to the problem. Let's follow the editor to learn more about "flowable workflow engine migration API instance analysis".
Process Migration API description
The process migration API service class can be obtained through the process engine class, as shown below:
ProcessMigrationService = processEngine.getProcessMigrationService ()
Note: this feature is only available in Flowable6.5 and above.
The following API can be used through processMigrationService:
ProcessInstanceMigrationBuilder createProcessInstanceMigrationBuilder (); ProcessInstanceMigrationBuilder createProcessInstanceMigrationBuilderFromProcessInstanceMigrationDocument (ProcessInstanceMigrationDocument document); ProcessInstanceMigrationValidationResult validateMigrationForProcessInstance (String processInstanceId, ProcessInstanceMigrationDocument processInstanceMigrationDocument); ProcessInstanceMigrationValidationResult validateMigrationForProcessInstancesOfProcessDefinition (String processDefinitionId, ProcessInstanceMigrationDocument processInstanceMigrationDocument); ProcessInstanceMigrationValidationResult validateMigrationForProcessInstancesOfProcessDefinition (String processDefinitionKey, int processDefinitionVersion, String processDefinitionTenantId, ProcessInstanceMigrationDocument processInstanceMigrationDocument); void migrateProcessInstance (String processInstanceId, ProcessInstanceMigrationDocument processInstanceMigrationDocument); void migrateProcessInstancesOfProcessDefinition (String processDefinitionId, ProcessInstanceMigrationDocument processInstanceMigrationDocument); void migrateProcessInstancesOfProcessDefinition (String processDefinitionKey, int processDefinitionVersion, String processDefinitionTenantId, ProcessInstanceMigrationDocument processInstanceMigrationDocument); Batch batchMigrateProcessInstancesOfProcessDefinition (String processDefinitionId, ProcessInstanceMigrationDocument processInstanceMigrationDocument); Batch batchMigrateProcessInstancesOfProcessDefinition (String processDefinitionKey, int processDefinitionVersion, String processDefinitionTenantId, ProcessInstanceMigrationDocument processInstanceMigrationDocument) ProcessInstanceBatchMigrationResult getResultsOfBatchProcessInstanceMigration (String migrationBatchId)
The above series of API can be summarized as follows:
Create a migration plan (ProcessInstanceMigrationBuilder), in which a series of migration logic can be set, such as migrating instances under that version to a specific version of the template
ValidateXX verifies that the migration logic can be performed.
The method at the beginning of migrateProcessInstance executes the migration plan synchronously, and as soon as the API is called, the engine starts to perform the migration work.
Batch migration instances at the beginning of batchMigrateXX. Batch processing can be used when a very large number of instances need to be migrated. This operation needs to start the timer, otherwise it will not take effect.
GetResultsOfBatchProcessInstanceMigration: gets the execution result of the batch.
Process Migration API usage
Next, take two versions of the process as examples to illustrate the process instance migration feature:
Flowchart of version 1:
two
The process of version 2:
The process of version 2 has one more task node than the process of version 1, and all other elements are the same.
For the demonstration video, please refer to the video:
Deploy version 1 process
Do the following:
/ * 1 * / @ Test public void deploy () {ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine (); System.out.println (processEngine); RepositoryService repositoryService = processEngine.getRepositoryService (); / / taskWithEventProcess.bpmn20.xml repositoryService .createdeployment () .addClasspathResource ("processMigrationService/2.1.bpmn20.xml") .deploy (); runtimeService.startProcessInstanceByKey ("a2") }
As soon as the process is deployed in the above code, the new instance is started. Currently, the instance is located on Node 1.
Instance migration
Next, start the deployment of the 2 process and implement the migration of 1 node to 2 nodes with version 2. The code is as follows:
@ Test public void batchMigrateProcessInstancesOfProcessDefinition2 () {String processDefinitionKey= "a2"; int processDefinitionVersion=1; String processDefinitionTenantId= ""; ProcessInstanceMigrationDocumentImpl processInstanceMigrationDocument = new ProcessInstanceMigrationDocumentImpl (); processInstanceMigrationDocument.setMigrateToProcessDefinition (processDefinitionKey,2); List activityMigrationMappings = new ArrayList (); ActivityMigrationMapping.OneToOneMapping mappingFor = ActivityMigrationMapping.createMappingFor ("sid-A8596132-C632-4DB0-81D6-5603D6516F3C", "sid-84BBB613-FB20-430B-B4C1-E60F4DA02CFB"); activityMigrationMappings.add (mappingFor) ProcessInstanceMigrationDocument.setActivityMigrationMappings (activityMigrationMappings); processMigrationService .migrateProcessInstance ("12505", processInstanceMigrationDocument);} process migration Flowable VS Camunda workflow
Compared with Camunda, the function of Flowable process instance migration is more weak and single. Some features may have something to do with the commercial version, so the open source function is relatively simple. Not as powerful as Camunda.
Flowable process instance migration function for query is not perfect, there is no large amount of query logic, it is not convenient for users to operate according to specific scenarios.
For batch processing module, it is not as powerful as Camunda, and the open source version of Flowable only supports batch migration of instances, but does not support other batch operations.
After the open source version of Flowable migrates instances in batches, the original historical data will be deleted, and Camunda will not delete historical data. Therefore, you must be careful when using this feature in Flowable to prevent historical data from being erased. The trace of the entire instance tree is not preserved.
The open source version of Flowable can migrate any data. Camunda will compare the source node and target node of the migration, and do not allow migration if it is not in a range. Flowable is not strictly controlled.
Camunda supports setting asynchronous or synchronous execution during migration, but Flowable does not.
Camunda supports setting whether to delete the original instance data information during migration, but Flowable does not.
Camunda supports setting whether node listener logic can be triggered during migration, but Flowable does not.
Both allow developers to set thresholds and rates for batch processing tasks.
Thank you for your reading, the above is the whole content of "flowable Workflow engine Migration API instance Analysis", learn friends to hurry up to operate it. I believe that the editor will certainly bring you better quality articles. Thank you for your support to the website!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.