Skip to content

Commit

Permalink
AAE-29208 Add Activiti Spring Cache Manager provider (#1645)
Browse files Browse the repository at this point in the history
* update activiti.version to 0.0.1-PR-4864-850-SNAPSHOT

* Add activiti-spring-cache-manager cache provider

* Add temporary logging for cache stats

* remove deprecated CachingProcessExtensionService

* update activiti.version to 0.0.1-PR-4864-852-SNAPSHOT

* Revert "Add temporary logging for cache stats"

This reverts commit 304cfab.

* update activiti.version to 0.0.1-PR-4864-855-SNAPSHOT

* Set default spring.activiti.caffeine.spec for activiti-cloud-starter-runtime-bundle

* Add temporary logging for cache stats

* Add engine cache configuration integration test

* Update EngineConfigurationIT process definition cache tests

* update activiti.version to 0.0.1-PR-4864-856-SNAPSHOT

* update activiti.version to 0.0.1-PR-4864-857-SNAPSHOT

* update activiti.version to 0.0.1-PR-4864-859-SNAPSHOT

* Add process definitions cache limit test coverage

* update activiti.version to 0.0.1-PR-4864-861-SNAPSHOT

* Cleanup SecurityTestConfiguration

* Revert "Add temporary logging for cache stats"

This reverts commit c801bcb.

* update activiti.version to 0.0.1-PR-4864-871-SNAPSHOT

* remove public modifier from EngineConfigurationIT Junit4 tests

* chore(deps): upgrade Activiti/Activiti to version 8.7.0-alpha.48

from: https://github.com/Activiti/Activiti
  • Loading branch information
igdianov authored Jan 2, 2025
1 parent 992f260 commit e658012
Show file tree
Hide file tree
Showing 22 changed files with 129 additions and 118 deletions.
2 changes: 1 addition & 1 deletion activiti-cloud-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<name>Activiti Cloud :: Runtime API Parent</name>
<packaging>pom</packaging>
<properties>
<activiti.version>8.7.0-alpha.47</activiti.version>
<activiti.version>8.7.0-alpha.48</activiti.version>
</properties>
<modules>
<module>activiti-cloud-api-dependencies</module>
Expand Down
2 changes: 1 addition & 1 deletion activiti-cloud-query-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<module>activiti-cloud-starter-query-rest</module>
</modules>
<properties>
<activiti.version>8.7.0-alpha.47</activiti.version>
<activiti.version>8.7.0-alpha.48</activiti.version>
</properties>
<!-- BoM Marker Dependencies -->
<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
import org.activiti.image.ProcessDiagramGenerator;
import org.activiti.image.impl.DefaultProcessDiagramGenerator;
import org.activiti.runtime.api.model.impl.APIProcessDefinitionConverter;
import org.activiti.spring.process.CachingProcessExtensionService;
import org.activiti.spring.process.ProcessExtensionService;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
Expand Down Expand Up @@ -279,9 +279,9 @@ public ProcessVariablesPayloadConverter processVariablesPayloadConverter(
@Bean
@ConditionalOnMissingBean
public ProcessDefinitionVariablesDecorator processDefinitionVariablesDecorator(
CachingProcessExtensionService cachingProcessExtensionService
ProcessExtensionService processExtensionService
) {
return new ProcessDefinitionVariablesDecorator(cachingProcessExtensionService);
return new ProcessDefinitionVariablesDecorator(processExtensionService);
}

@Bean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@
import java.util.stream.Collectors;
import org.activiti.api.runtime.model.impl.VariableDefinitionImpl;
import org.activiti.cloud.api.process.model.ExtendedCloudProcessDefinition;
import org.activiti.spring.process.CachingProcessExtensionService;
import org.activiti.spring.process.ProcessExtensionService;
import org.activiti.spring.process.model.VariableDefinition;

public class ProcessDefinitionVariablesDecorator implements ProcessDefinitionDecorator {

private static final String HANDLED_VALUE = "variables";

private final CachingProcessExtensionService processExtensionService;
private final ProcessExtensionService processExtensionService;

public ProcessDefinitionVariablesDecorator(CachingProcessExtensionService processExtensionService) {
public ProcessDefinitionVariablesDecorator(ProcessExtensionService processExtensionService) {
this.processExtensionService = processExtensionService;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import java.util.Map;
import org.activiti.cloud.api.process.model.ExtendedCloudProcessDefinition;
import org.activiti.cloud.api.process.model.impl.CloudProcessDefinitionImpl;
import org.activiti.spring.process.CachingProcessExtensionService;
import org.activiti.spring.process.ProcessExtensionService;
import org.activiti.spring.process.model.Extension;
import org.activiti.spring.process.model.VariableDefinition;
import org.junit.jupiter.api.Test;
Expand All @@ -39,7 +39,7 @@ class ProcessDefinitionVariablesDecoratorTest {
private ProcessDefinitionVariablesDecorator processDefinitionVariablesDecorator;

@Mock
private CachingProcessExtensionService processExtensionService;
private ProcessExtensionService processExtensionService;

@ParameterizedTest
@CsvSource({ "variables, true", "VARIABLES, true", "else, false" })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
import org.activiti.engine.ManagementService;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.impl.context.Context;
import org.activiti.spring.process.CachingProcessExtensionService;
import org.activiti.spring.process.ProcessExtensionService;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
Expand Down Expand Up @@ -351,7 +351,7 @@ public CloudProcessUpdatedProducer cloudProcessUpdatedProducer(
@ConditionalOnMissingBean
public ToCloudVariableEventConverter cloudVariableEventConverter(
RuntimeBundleInfoAppender runtimeBundleInfoAppender,
CachingProcessExtensionService processExtensionService
ProcessExtensionService processExtensionService
) {
return new ToCloudVariableEventConverter(runtimeBundleInfoAppender, processExtensionService);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@
import org.activiti.cloud.api.model.shared.impl.events.CloudVariableDeletedEventImpl;
import org.activiti.cloud.api.model.shared.impl.events.CloudVariableUpdatedEventImpl;
import org.activiti.core.common.model.connector.VariableDefinition;
import org.activiti.spring.process.CachingProcessExtensionService;
import org.activiti.spring.process.ProcessExtensionService;
import org.activiti.spring.process.model.Extension;

public class ToCloudVariableEventConverter {

private final RuntimeBundleInfoAppender runtimeBundleInfoAppender;
private final CachingProcessExtensionService processExtensionService;
private final ProcessExtensionService processExtensionService;

public ToCloudVariableEventConverter(
RuntimeBundleInfoAppender runtimeBundleInfoAppender,
CachingProcessExtensionService processExtensionService
ProcessExtensionService processExtensionService
) {
this.runtimeBundleInfoAppender = runtimeBundleInfoAppender;
this.processExtensionService = processExtensionService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import org.activiti.api.runtime.model.impl.VariableInstanceImpl;
import org.activiti.cloud.api.model.shared.events.CloudVariableCreatedEvent;
import org.activiti.cloud.api.model.shared.impl.events.CloudVariableCreatedEventImpl;
import org.activiti.spring.process.CachingProcessExtensionService;
import org.activiti.spring.process.ProcessExtensionService;
import org.activiti.spring.process.model.Extension;
import org.activiti.spring.process.model.VariableDefinition;
import org.junit.jupiter.api.Test;
Expand All @@ -45,7 +45,7 @@ class ToCloudVariableEventConverterTest {
private RuntimeBundleInfoAppender runtimeBundleInfoAppender;

@Mock
private CachingProcessExtensionService processExtensionService;
private ProcessExtensionService processExtensionService;

@Test
void should_returnNull_whenPropertiesAreEmpty() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
import org.activiti.engine.ActivitiException;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.impl.util.IoUtil;
import org.activiti.spring.process.CachingProcessExtensionService;
import org.activiti.spring.process.ProcessExtensionService;
import org.activiti.spring.process.model.Extension;
import org.activiti.spring.process.model.Mapping.SourceMappingType;
import org.activiti.spring.process.model.ProcessConstantsMapping;
Expand Down Expand Up @@ -94,7 +94,7 @@ public class ProcessDefinitionControllerImpl implements ProcessDefinitionControl

private final ProcessDefinitionService processDefinitionService;

private final CachingProcessExtensionService cachingProcessExtensionService;
private final ProcessExtensionService processExtensionService;

@Autowired
public ProcessDefinitionControllerImpl(
Expand All @@ -106,7 +106,7 @@ public ProcessDefinitionControllerImpl(
AlfrescoPagedModelAssembler<ProcessDefinition> pagedCollectionModelAssembler,
SpringPageConverter pageConverter,
ProcessDefinitionService processDefinitionService,
CachingProcessExtensionService cachingProcessExtensionService
ProcessExtensionService processExtensionService
) {
this.repositoryService = repositoryService;
this.processDiagramGenerator = processDiagramGenerator;
Expand All @@ -117,7 +117,7 @@ public ProcessDefinitionControllerImpl(
this.pagedCollectionModelAssembler = pagedCollectionModelAssembler;
this.pageConverter = pageConverter;
this.processDefinitionService = processDefinitionService;
this.cachingProcessExtensionService = cachingProcessExtensionService;
this.processExtensionService = processExtensionService;
}

@Override
Expand Down Expand Up @@ -242,7 +242,7 @@ private ExtensionsStartEventId getProcessExtensionsForStartEvent(String id, bool
if (startEvent.isPresent()) {
return new ExtensionsStartEventId(
startEvent.get().getId(),
cachingProcessExtensionService.getExtensionsForId(id)
processExtensionService.getExtensionsForId(id)
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
import org.activiti.engine.RuntimeService;
import org.activiti.image.exception.ActivitiInterchangeInfoNotFoundException;
import org.activiti.runtime.api.query.impl.PageImpl;
import org.activiti.spring.process.CachingProcessExtensionService;
import org.activiti.spring.process.ProcessExtensionService;
import org.activiti.spring.process.conf.ProcessExtensionsAutoConfiguration;
import org.activiti.spring.process.model.ConstantDefinition;
import org.activiti.spring.process.model.Extension;
Expand Down Expand Up @@ -137,7 +137,7 @@ class ProcessDefinitionControllerImplIT {
private CloudProcessDeployedProducer processDeployedProducer;

@MockBean
private CachingProcessExtensionService cachingProcessExtensionService;
private ProcessExtensionService processExtensionService;

@MockBean
private SecurityContextPrincipalProvider securityContextPrincipalProvider;
Expand Down Expand Up @@ -258,7 +258,7 @@ void getProcessDefinitionsWithVariables() throws Exception {
givenVariableDefinition.setDisplayName("Var name");
extension.setProperties(Map.of("var1", givenVariableDefinition));

when(cachingProcessExtensionService.getExtensionsForId("procId")).thenReturn(extension);
when(processExtensionService.getExtensionsForId("procId")).thenReturn(extension);

mockMvc
.perform(
Expand Down Expand Up @@ -430,7 +430,7 @@ void should_getProcessModelStaticValuesMappingForStartEvent_when_hasStartEventFo
extension.setMappings(Map.of("startEvent", startEventMapping));
extension.setProperties(Map.of("variableRef", givenVariableDefinition));

when(cachingProcessExtensionService.getExtensionsForId("procId")).thenReturn(extension);
when(processExtensionService.getExtensionsForId("procId")).thenReturn(extension);

MvcResult result = mockMvc
.perform(get("/v1/process-definitions/{id}/static-values", procId).accept(APPLICATION_JSON))
Expand Down Expand Up @@ -492,7 +492,7 @@ void should_getEmptyMapForProcessModelStaticValuesMappingForStartEvent_when_star
extension.setMappings(Map.of("startEvent", startEventMapping));
extension.setProperties(Map.of("variableRef", givenVariableDefinition));

when(cachingProcessExtensionService.getExtensionsForId("procId")).thenReturn(extension);
when(processExtensionService.getExtensionsForId("procId")).thenReturn(extension);

MvcResult result = mockMvc
.perform(get("/v1/process-definitions/{id}/static-values", procId).accept(APPLICATION_JSON))
Expand Down Expand Up @@ -545,7 +545,7 @@ void should_getEmptyMapForProcessModelStaticValuesMappingForStartEvent_when_hasN
Extension extension = new Extension();
extension.setProperties(Map.of("variableRef", givenVariableDefinition));

when(cachingProcessExtensionService.getExtensionsForId("procId")).thenReturn(extension);
when(processExtensionService.getExtensionsForId("procId")).thenReturn(extension);

MvcResult result = mockMvc
.perform(get("/v1/process-definitions/{id}/static-values", procId).accept(APPLICATION_JSON))
Expand Down Expand Up @@ -606,7 +606,7 @@ void should_getEmptyMapForProcessModelStaticValuesMappingForStartEvent_when_hasN
extension.setMappings(Map.of("startEvent", startEventMapping));
extension.setProperties(Map.of("variableRef", givenVariableDefinition));

when(cachingProcessExtensionService.getExtensionsForId("procId")).thenReturn(extension);
when(processExtensionService.getExtensionsForId("procId")).thenReturn(extension);

MvcResult result = mockMvc
.perform(get("/v1/process-definitions/{id}/static-values", procId).accept(APPLICATION_JSON))
Expand Down Expand Up @@ -646,7 +646,7 @@ void should_getEmptyMapForProcessModelStaticValuesMappingForStartEvent_when_hasN
bpmnModel.getProcesses().add(process);
when(repositoryService.getBpmnModel(procId)).thenReturn(bpmnModel);

when(cachingProcessExtensionService.getExtensionsForId("procId")).thenReturn(null);
when(processExtensionService.getExtensionsForId("procId")).thenReturn(null);

MvcResult result = mockMvc
.perform(get("/v1/process-definitions/{id}/static-values", procId).accept(APPLICATION_JSON))
Expand Down Expand Up @@ -703,7 +703,7 @@ void should_getProcessModelConstantsForStartEvent_when_hasStartEventFormAndConst
Extension extension = new Extension();
extension.setConstants(Map.of("startEvent", givenConstantsDefinition));

when(cachingProcessExtensionService.getExtensionsForId("procId")).thenReturn(extension);
when(processExtensionService.getExtensionsForId("procId")).thenReturn(extension);

MvcResult result = mockMvc
.perform(get("/v1/process-definitions/{id}/constant-values", procId).accept(APPLICATION_JSON))
Expand Down Expand Up @@ -759,7 +759,7 @@ void should_getProcessModelConstantsForStartEvent_when_hasNoStartEventFormAndCon
Extension extension = new Extension();
extension.setConstants(Map.of("startEvent", givenConstantsDefinition));

when(cachingProcessExtensionService.getExtensionsForId("procId")).thenReturn(extension);
when(processExtensionService.getExtensionsForId("procId")).thenReturn(extension);

MvcResult result = mockMvc
.perform(get("/v1/process-definitions/{id}/constant-values", procId).accept(APPLICATION_JSON))
Expand Down Expand Up @@ -810,7 +810,7 @@ void should_getEmptyMapForProcessModelConstantsForStartEvent_when_startEventHasN

Extension extension = new Extension();

when(cachingProcessExtensionService.getExtensionsForId("procId")).thenReturn(extension);
when(processExtensionService.getExtensionsForId("procId")).thenReturn(extension);

MvcResult result = mockMvc
.perform(get("/v1/process-definitions/{id}/constant-values", procId).accept(APPLICATION_JSON))
Expand Down Expand Up @@ -862,7 +862,7 @@ void should_getEmptyMapForProcessModelConstantsMappingForStartEvent_when_hasForm

Extension extension = new Extension();

when(cachingProcessExtensionService.getExtensionsForId("procId")).thenReturn(extension);
when(processExtensionService.getExtensionsForId("procId")).thenReturn(extension);

MvcResult result = mockMvc
.perform(get("/v1/process-definitions/{id}/constant-values", procId).accept(APPLICATION_JSON))
Expand Down Expand Up @@ -913,7 +913,7 @@ void should_getEmptyMapForProcessModelConstantsMappingForStartEvent_when_hasNoSt
Extension extension = new Extension();
extension.setConstants(Map.of("startEvent", givenConstantsDefinition));

when(cachingProcessExtensionService.getExtensionsForId("procId")).thenReturn(extension);
when(processExtensionService.getExtensionsForId("procId")).thenReturn(extension);

MvcResult result = mockMvc
.perform(get("/v1/process-definitions/{id}/constant-values", procId).accept(APPLICATION_JSON))
Expand Down Expand Up @@ -962,7 +962,7 @@ void should_getEmptyMapForProcessModelConstantsMappingForStartEvent_when_hasNoEx
variableMapping.setType(SourceMappingType.VARIABLE);
startEventMapping.setInputs(Map.of("value", valueMapping, "variable", variableMapping));

when(cachingProcessExtensionService.getExtensionsForId("procId")).thenReturn(null);
when(processExtensionService.getExtensionsForId("procId")).thenReturn(null);

MvcResult result = mockMvc
.perform(get("/v1/process-definitions/{id}/constant-values", procId).accept(APPLICATION_JSON))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
import org.activiti.engine.ManagementService;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.RuntimeService;
import org.activiti.spring.process.CachingProcessExtensionService;
import org.activiti.spring.process.ProcessExtensionService;
import org.activiti.spring.process.variable.VariableValidationService;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -117,7 +117,7 @@ class ProcessInstanceVariableControllerImplIT {
private CloudProcessDeployedProducer processDeployedProducer;

@MockBean
private CachingProcessExtensionService cachingProcessExtensionService;
private ProcessExtensionService processExtensionService;

@MockBean
private SecurityContextPrincipalProvider securityContextPrincipalProvider;
Expand All @@ -140,7 +140,7 @@ void setUp() {
assertThat(resourcesAssembler).isNotNull();
assertThat(processEngineChannels).isNotNull();
assertThat(processDeployedProducer).isNotNull();
assertThat(cachingProcessExtensionService).isNotNull();
assertThat(processExtensionService).isNotNull();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ spring.activiti.deploymentMode=never-fail
spring.activiti.async-executor.default-async-job-acquire-wait-time-in-millis=5000
spring.activiti.async-executor.default-timer-job-acquire-wait-time-in-millis=5000

spring.activiti.process-definition-cache-name=processDefinitions
activiti.spring.cache-manager.caches.processDefinitions.caffeine.spec=maximumSize=${spring.activiti.process-definition-cache-limit:1000}, expireAfterAccess=10m, recordStats

#ensures that producer participates in the Spring transactions
spring.cloud.stream.rabbit.bindings.auditProducer.producer.transacted=${ACT_AUDIT_PRODUCER_TRANSACTED:true}
spring.cloud.stream.kafka.binder.transaction.transactionIdPrefix=${ACT_AUDIT_PRODUCER_TRANSACTION_ID_PREFIX:tx-}
Expand Down
Loading

0 comments on commit e658012

Please sign in to comment.