Skip to content

Commit be5dc01

Browse files
committed
Remove async history support
1 parent 5ba6010 commit be5dc01

File tree

127 files changed

+90
-12558
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

127 files changed

+90
-12558
lines changed

modules/flowable-cmmn-engine-configurator/src/main/java/org/flowable/cmmn/engine/configurator/CmmnEngineConfigurator.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,6 @@ protected void copyProcessEngineProperties(ProcessEngineConfigurationImpl proces
125125
// The job handlers will be added in the CmmnEngineConfiguration itself
126126
cmmnEngineConfiguration.setAsyncHistoryEnabled(true);
127127
cmmnEngineConfiguration.setAsyncHistoryExecutor(asyncHistoryExecutor);
128-
cmmnEngineConfiguration.setAsyncHistoryJsonGroupingEnabled(processEngineConfiguration.isAsyncHistoryJsonGroupingEnabled());
129-
cmmnEngineConfiguration.setAsyncHistoryJsonGroupingThreshold(processEngineConfiguration.getAsyncHistoryJsonGroupingThreshold());
130-
cmmnEngineConfiguration.setAsyncHistoryJsonGzipCompressionEnabled(processEngineConfiguration.isAsyncHistoryJsonGzipCompressionEnabled());
131128

132129
cmmnEngineConfiguration.setAsyncHistoryTaskExecutor(processEngineConfiguration.getAsyncHistoryTaskExecutor());
133130

modules/flowable-cmmn-engine-configurator/src/test/java/org/flowable/cmmn/test/CmmnEngineConfiguratorAsyncHistoryTest.java

Lines changed: 40 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,17 @@
1414

1515
import static org.assertj.core.api.Assertions.assertThat;
1616

17-
import org.flowable.cmmn.api.runtime.PlanItemInstanceState;
1817
import org.flowable.cmmn.engine.CmmnEngine;
1918
import org.flowable.cmmn.engine.CmmnEngines;
20-
import org.flowable.cmmn.engine.impl.history.async.CmmnAsyncHistoryConstants;
2119
import org.flowable.cmmn.engine.test.impl.CmmnJobTestHelper;
2220
import org.flowable.common.engine.api.async.AsyncTaskExecutor;
2321
import org.flowable.engine.ProcessEngine;
2422
import org.flowable.engine.ProcessEngineConfiguration;
25-
import org.flowable.engine.impl.history.async.HistoryJsonConstants;
26-
import org.flowable.job.api.HistoryJob;
23+
import org.flowable.engine.impl.util.CommandContextUtil;
24+
import org.flowable.job.service.HistoryJobService;
2725
import org.flowable.job.service.JobServiceConfiguration;
2826
import org.flowable.job.service.impl.asyncexecutor.AsyncExecutor;
27+
import org.flowable.job.service.impl.persistence.entity.HistoryJobEntity;
2928
import org.junit.After;
3029
import org.junit.Before;
3130
import org.junit.Test;
@@ -54,9 +53,6 @@ public void cleanup() {
5453
.createDeploymentQuery()
5554
.list()
5655
.forEach(deployment -> cmmnEngine.getCmmnRepositoryService().deleteDeployment(deployment.getId(), true));
57-
// Execute history jobs for the delete deployments
58-
processEngine.getManagementService().createHistoryJobQuery().list()
59-
.forEach(historyJob -> processEngine.getManagementService().executeHistoryJob(historyJob.getId()));
6056

6157
cmmnEngine.close();
6258
processEngine.close();
@@ -79,66 +75,48 @@ public void testSharedAsyncHistoryExecutor() {
7975
assertThat(processEngine.getProcessEngineConfiguration().getAsyncHistoryExecutor().getJobServiceConfiguration().getHistoryJobExecutionScope())
8076
.isEqualTo(JobServiceConfiguration.JOB_EXECUTION_SCOPE_ALL);
8177

82-
// 2 job handlers / engine
83-
assertThat(processEngineAsyncExecutor.getJobServiceConfiguration().getHistoryJobHandlers()).hasSize(4);
84-
85-
// Deploy and start test processes/cases
86-
// Trigger one plan item instance to start the process
87-
processEngine.getRepositoryService().createDeployment().addClasspathResource("org/flowable/cmmn/test/oneTaskProcess.bpmn20.xml").deploy();
88-
cmmnEngine.getCmmnRepositoryService().createDeployment()
89-
.addClasspathResource("org/flowable/cmmn/test/ProcessTaskTest.testOneTaskProcessNonBlocking.cmmn").deploy();
90-
cmmnEngine.getCmmnRuntimeService().createCaseInstanceBuilder().caseDefinitionKey("myCase").start();
91-
cmmnEngine.getCmmnRuntimeService().triggerPlanItemInstance(
92-
cmmnEngine.getCmmnRuntimeService().createPlanItemInstanceQuery().planItemInstanceState(PlanItemInstanceState.ACTIVE).singleResult().getId());
93-
94-
// As async history is enabled, there should be no historical entries yet, but there should be history jobs
95-
assertThat(cmmnEngine.getCmmnHistoryService().createHistoricCaseInstanceQuery().count()).isZero();
96-
assertThat(processEngine.getHistoryService().createHistoricProcessInstanceQuery().count()).isZero();
97-
98-
// 3 history jobs expected:
99-
// - one for the case instance start
100-
// - one for the plan item instance trigger
101-
// - one for the process instance start
102-
assertThat(cmmnEngine.getCmmnManagementService().createHistoryJobQuery().count()).isEqualTo(3);
103-
assertThat(processEngine.getManagementService().createHistoryJobQuery().count()).isEqualTo(3);
104-
105-
// Expected 2 jobs originating from the cmmn engine and 1 for the process engine
106-
int cmmnHistoryJobs = 0;
107-
int bpmnHistoryJobs = 0;
108-
for (HistoryJob historyJob : cmmnEngine.getCmmnManagementService().createHistoryJobQuery().list()) {
109-
if (historyJob.getJobHandlerType().equals(CmmnAsyncHistoryConstants.JOB_HANDLER_TYPE_DEFAULT_ASYNC_HISTORY)
110-
|| historyJob.getJobHandlerType().equals(CmmnAsyncHistoryConstants.JOB_HANDLER_TYPE_DEFAULT_ASYNC_HISTORY_ZIPPED)) {
111-
cmmnHistoryJobs++;
112-
} else if (historyJob.getJobHandlerType().equals(HistoryJsonConstants.JOB_HANDLER_TYPE_DEFAULT_ASYNC_HISTORY)
113-
|| historyJob.getJobHandlerType().equals(HistoryJsonConstants.JOB_HANDLER_TYPE_DEFAULT_ASYNC_HISTORY_ZIPPED)) {
114-
bpmnHistoryJobs++;
115-
}
116-
117-
// Execution scope should be all (see the CmmnEngineConfigurator)
118-
assertThat(historyJob.getScopeType()).isEqualTo(JobServiceConfiguration.JOB_EXECUTION_SCOPE_ALL);
119-
}
120-
assertThat(bpmnHistoryJobs).isEqualTo(1);
121-
assertThat(cmmnHistoryJobs).isEqualTo(2);
78+
// 1 job handlers / engine
79+
assertThat(processEngineAsyncExecutor.getJobServiceConfiguration().getHistoryJobHandlers())
80+
.containsOnlyKeys("bpmn-test-history-job-handler", "cmmn-test-history-job-handler");
81+
82+
processEngine.getManagementService()
83+
.executeCommand(commandContext -> {
84+
HistoryJobService historyJobService = CommandContextUtil.getProcessEngineConfiguration(commandContext)
85+
.getJobServiceConfiguration()
86+
.getHistoryJobService();
87+
88+
HistoryJobEntity historyJob = historyJobService.createHistoryJob();
89+
historyJob.setScopeType(JobServiceConfiguration.JOB_EXECUTION_SCOPE_ALL);
90+
historyJob.setJobHandlerType("bpmn-test-history-job-handler");
91+
historyJob.setRetries(3);
92+
historyJob.setCreateTime(commandContext.getClock().getCurrentTime());
93+
historyJobService.scheduleHistoryJob(historyJob);
94+
return null;
95+
});
96+
97+
cmmnEngine.getCmmnEngineConfiguration()
98+
.getCommandExecutor()
99+
.execute(commandContext -> {
100+
HistoryJobService historyJobService = org.flowable.cmmn.engine.impl.util.CommandContextUtil.getCmmnEngineConfiguration(commandContext)
101+
.getJobServiceConfiguration()
102+
.getHistoryJobService();
103+
104+
HistoryJobEntity historyJob = historyJobService.createHistoryJob();
105+
historyJob.setScopeType(JobServiceConfiguration.JOB_EXECUTION_SCOPE_ALL);
106+
historyJob.setJobHandlerType("cmmn-test-history-job-handler");
107+
historyJob.setRetries(3);
108+
historyJob.setCreateTime(commandContext.getClock().getCurrentTime());
109+
historyJobService.scheduleHistoryJob(historyJob);
110+
return null;
111+
});
112+
113+
assertThat(cmmnEngine.getCmmnManagementService().createHistoryJobQuery().count()).isEqualTo(2);
114+
assertThat(processEngine.getManagementService().createHistoryJobQuery().count()).isEqualTo(2);
122115

123116
// Starting the async history executor should process all of these
124117
CmmnJobTestHelper.waitForAsyncHistoryExecutorToProcessAllJobs(cmmnEngine.getCmmnEngineConfiguration(), 10000L, 200L, true);
125118

126-
assertThat(cmmnEngine.getCmmnHistoryService().createHistoricCaseInstanceQuery().count()).isEqualTo(1);
127-
assertThat(processEngine.getHistoryService().createHistoricProcessInstanceQuery().count()).isEqualTo(1);
128119
assertThat(cmmnEngine.getCmmnManagementService().createHistoryJobQuery().count()).isZero();
129120
assertThat(processEngine.getManagementService().createHistoryJobQuery().count()).isZero();
130121
}
131-
132-
@Test
133-
public void testProcessAsyncHistoryNotChanged() {
134-
// This test validates that the shared async history executor does not intervene when running a process regularly
135-
processEngine.getRepositoryService().createDeployment().addClasspathResource("org/flowable/cmmn/test/oneTaskProcess.bpmn20.xml").deploy();
136-
processEngine.getRuntimeService().startProcessInstanceByKey("oneTask");
137-
assertThat(processEngine.getManagementService().createHistoryJobQuery().count()).isEqualTo(1);
138-
139-
HistoryJob historyJob = processEngine.getManagementService().createHistoryJobQuery().singleResult();
140-
assertThat(historyJob.getJobHandlerType()).isEqualTo(HistoryJsonConstants.JOB_HANDLER_TYPE_DEFAULT_ASYNC_HISTORY);
141-
processEngine.getManagementService().executeHistoryJob(historyJob.getId());
142-
}
143-
144122
}
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,40 @@
11
/* Licensed under the Apache License, Version 2.0 (the "License");
22
* you may not use this file except in compliance with the License.
33
* You may obtain a copy of the License at
4-
*
4+
*
55
* http://www.apache.org/licenses/LICENSE-2.0
6-
*
6+
*
77
* Unless required by applicable law or agreed to in writing, software
88
* distributed under the License is distributed on an "AS IS" BASIS,
99
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1010
* See the License for the specific language governing permissions and
1111
* limitations under the License.
1212
*/
13-
package org.flowable.job.service.impl.history.async.transformer;
14-
15-
import java.util.List;
13+
package org.flowable.cmmn.test;
1614

1715
import org.flowable.common.engine.impl.interceptor.CommandContext;
16+
import org.flowable.job.service.HistoryJobHandler;
17+
import org.flowable.job.service.JobServiceConfiguration;
1818
import org.flowable.job.service.impl.persistence.entity.HistoryJobEntity;
1919

20-
import com.fasterxml.jackson.databind.node.ObjectNode;
20+
/**
21+
* @author Filip Hrisafov
22+
*/
23+
public class TestHistoryJobHandler implements HistoryJobHandler {
2124

22-
public interface HistoryJsonTransformer {
23-
24-
String FIELD_NAME_TYPE = "type";
25-
String FIELD_NAME_DATA = "data";
25+
protected final String type;
2626

27-
List<String> getTypes();
27+
public TestHistoryJobHandler(String type) {
28+
this.type = type;
29+
}
2830

29-
boolean isApplicable(ObjectNode historicalData, CommandContext commandContext);
31+
@Override
32+
public String getType() {
33+
return type;
34+
}
3035

31-
void transformJson(HistoryJobEntity job, ObjectNode historicalData, CommandContext commandContext);
36+
@Override
37+
public void execute(HistoryJobEntity job, String configuration, CommandContext commandContext, JobServiceConfiguration jobServiceConfiguration) {
3238

39+
}
3340
}

modules/flowable-cmmn-engine-configurator/src/test/resources/flowable.async.history.cfg.xml

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,20 @@
2020
</constructor-arg>
2121
</bean>
2222

23+
<bean id="cmmnEngineConfiguration" class="org.flowable.cmmn.engine.CmmnEngineConfiguration">
24+
<property name="customHistoryJobHandlers">
25+
<list>
26+
<bean class="org.flowable.cmmn.test.TestHistoryJobHandler">
27+
<constructor-arg name="type" value="cmmn-test-history-job-handler" />
28+
</bean>
29+
</list>
30+
</property>
31+
</bean>
32+
33+
<bean id="cmmnEngineConfigurator" class="org.flowable.cmmn.engine.configurator.CmmnEngineConfigurator">
34+
<property name="cmmnEngineConfiguration" ref="cmmnEngineConfiguration"/>
35+
</bean>
36+
2337
<bean id="processEngineConfiguration" class="org.flowable.engine.impl.cfg.StandaloneProcessEngineConfiguration">
2438
<property name="dataSource" ref="dataSource"/>
2539

@@ -34,16 +48,22 @@
3448

3549
<property name="asyncHistoryEnabled" value="true" />
3650
<property name="asyncHistoryExecutorActivate" value="false" />
37-
<property name="asyncHistoryJsonGroupingEnabled" value="true" />
38-
<property name="asyncHistoryJsonGroupingThreshold" value="1" />
3951

4052
<property name="defaultFailedJobWaitTime" value="1" />
4153
<property name="asyncFailedJobWaitTime" value="1" />
4254
<property name="asyncHistoryExecutorDefaultAsyncJobAcquireWaitTime" value="100" />
4355

4456
<property name="configurators">
4557
<list>
46-
<bean class="org.flowable.cmmn.engine.configurator.CmmnEngineConfigurator" />
58+
<ref bean="cmmnEngineConfigurator" />
59+
</list>
60+
</property>
61+
62+
<property name="customHistoryJobHandlers">
63+
<list>
64+
<bean class="org.flowable.cmmn.test.TestHistoryJobHandler">
65+
<constructor-arg name="type" value="bpmn-test-history-job-handler" />
66+
</bean>
4767
</list>
4868
</property>
4969
</bean>

0 commit comments

Comments
 (0)