Skip to content

Commit

Permalink
Merge pull request #6 from camunda-community-hub/feature/issue-5_furt…
Browse files Browse the repository at this point in the history
…her-migration-scenarios

feature: further migration scenarios
  • Loading branch information
stephanpelikan authored Mar 13, 2023
2 parents 9b8b3db + 89fe5bf commit fbeab7b
Show file tree
Hide file tree
Showing 10 changed files with 276 additions and 117 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

This is an adapter which implements the binding of the [VanillaBP SPI](https://github.com/vanillabp/spi-for-java) in order to run business processes using [Camunda 7](https://docs.camunda.org).

If you are interested in migrating to [Camunda 8](https://docs.camunda.io) then checkout the [drop-in replacement adapter for Camunda 8](https://github.com/camunda-community-hub/vanillabp-camunda8-adapter).
If you are interested in migrating to [Camunda 8](https://docs.camunda.io) then checkout the [drop-in replacement adapter for Camunda 8](https://github.com/camunda-community-hub/vanillabp-camunda8-adapter) as well as the [documentation of migration scenarios](https://github.com/vanillabp/spring-boot-support#migrating-from-one-bpm-system-to-another).

## Runtime environments

Expand Down
16 changes: 9 additions & 7 deletions spring-boot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ Additionally, in a clustered environment during rolling deployment, to not start

```yaml
camunda:
bpm:
job-execution:
deployment-aware: true
bpm:
job-execution:
deployment-aware: true
```
### SPI Binding validation
Expand Down Expand Up @@ -129,16 +129,18 @@ public class TaxiRide {
On introducing VanillaBP one might to keep some of the BPMNs unchanged. Therefore, automatic re-defining "Async before" and "Async after" can be disabled in general:

```yaml
camunda:
vanillabp:
vanillabp:
adapters:
camunda7:
use-bpmn-async-definitions: true
```

or just for particular process definitions:

```yaml
camunda:
vanillabp:
vanillabp:
adapters:
camunda7:
bpmn-async-definitions:
- workflow-module-id: ABC1
bpmn-process-id: XYZ1
Expand Down
2 changes: 1 addition & 1 deletion spring-boot/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<dependency>
<groupId>io.vanillabp</groupId>
<artifactId>spring-boot-support</artifactId>
<version>1.0.2</version>
<version>1.0.3</version>
</dependency>
<dependency>
<groupId>org.camunda.bpm.springboot</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,45 @@
import io.vanillabp.camunda7.wiring.TaskWiringBpmnParseListener;
import io.vanillabp.springboot.adapter.AdapterConfigurationBase;
import io.vanillabp.springboot.adapter.SpringDataUtil;
import io.vanillabp.springboot.adapter.VanillaBpProperties;
import org.camunda.bpm.engine.ProcessEngine;
import org.camunda.bpm.engine.spring.application.SpringProcessApplication;
import org.camunda.bpm.spring.boot.starter.annotation.EnableProcessApplication;
import org.springframework.beans.factory.InjectionPoint;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.boot.autoconfigure.AutoConfigurationPackage;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Lazy;
import org.springframework.context.annotation.Scope;
import org.springframework.data.repository.CrudRepository;

@AutoConfigurationPackage(basePackageClasses = Camunda7AdapterConfiguration.class)
@EnableProcessApplication("org.camunda.bpm.spring.boot.starter.SpringBootProcessApplication")
public class Camunda7AdapterConfiguration extends AdapterConfigurationBase<Camunda7ProcessService<?>> {

public static final String ADAPTER_ID = "camunda7";

@Value("${workerId}")
private String workerId;

@Autowired
private ApplicationContext applicationContext;

@Lazy
@Autowired
private ProcessEngine processEngine; // lazy to avoid circular dependency on bean creation

@Autowired
private ApplicationEventPublisher applicationEventPublisher;

@Override
public String getAdapterId() {

return ADAPTER_ID;

}

@Bean
public Camunda7AdapterProperties camunda7AdapterProperties() {

Expand All @@ -44,11 +58,13 @@ public Camunda7AdapterProperties camunda7AdapterProperties() {

@Bean
public Camunda7DeploymentAdapter camunda7DeploymentAdapter(
final VanillaBpProperties properties,
final SpringProcessApplication processApplication,
final ProcessEngine processEngine,
final Camunda7TaskWiring taskWiring) {

return new Camunda7DeploymentAdapter(
properties,
processApplication,
taskWiring,
processEngine);
Expand Down Expand Up @@ -109,27 +125,23 @@ public Camunda7TaskWiringPlugin taskWiringCamundaPlugin(

}

@SuppressWarnings("unchecked")
@Bean
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public <DE> Camunda7ProcessService<?> camundaProcessService(
final ApplicationEventPublisher applicationEventPublisher,
@Lazy final ProcessEngine processEngine, // lazy to avoid circular dependency on bean creation
@Override
public <DE> Camunda7ProcessService<?> newProcessServiceImplementation(
final SpringDataUtil springDataUtil,
final InjectionPoint injectionPoint) throws Exception {

return registerProcessService(
springDataUtil,
injectionPoint,
(workflowAggregateRepository, workflowAggregateClass) ->
new Camunda7ProcessService<DE>(
applicationEventPublisher,
processEngine,
workflowAggregate -> springDataUtil.getId(workflowAggregate),
(CrudRepository<DE, String>) workflowAggregateRepository,
(Class<DE>) workflowAggregateClass)
);

final Class<DE> workflowAggregateClass,
final CrudRepository<DE, String> workflowAggregateRepository) {

final var result = new Camunda7ProcessService<DE>(
applicationEventPublisher,
processEngine,
workflowAggregate -> springDataUtil.getId(workflowAggregate),
workflowAggregateRepository,
workflowAggregateClass);

putConnectableService(workflowAggregateClass, result);

return result;
}

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package io.vanillabp.camunda7.deployment;

import io.vanillabp.camunda7.Camunda7AdapterConfiguration;
import io.vanillabp.camunda7.wiring.Camunda7TaskWiring;
import io.vanillabp.camunda7.wiring.TaskWiringBpmnParseListener;
import io.vanillabp.springboot.adapter.ModuleAwareBpmnDeployment;
import io.vanillabp.springboot.adapter.VanillaBpProperties;
import org.camunda.bpm.engine.ProcessEngine;
import org.camunda.bpm.engine.repository.ResumePreviousBy;
import org.camunda.bpm.engine.spring.application.SpringProcessApplication;
Expand All @@ -16,19 +19,20 @@
public class Camunda7DeploymentAdapter extends ModuleAwareBpmnDeployment {

private static final Logger logger = LoggerFactory.getLogger(Camunda7DeploymentAdapter.class);

private final ProcessEngine processEngine;

private final SpringProcessApplication processApplication;

private final Camunda7TaskWiring taskWiring;

public Camunda7DeploymentAdapter(
final VanillaBpProperties properties,
final SpringProcessApplication processApplication,
final Camunda7TaskWiring taskWiring,
final ProcessEngine processEngine) {

super();
super(properties);
this.processEngine = processEngine;
this.processApplication = processApplication;
this.taskWiring = taskWiring;
Expand All @@ -42,6 +46,13 @@ protected Logger getLogger() {

}

@Override
protected String getAdapterId() {

return Camunda7AdapterConfiguration.ADAPTER_ID;

}

@Override
@PostConstruct
public void deployAllWorkflowModules() {
Expand All @@ -55,6 +66,7 @@ public void deployAllWorkflowModules() {
@Override
protected void doDeployment(
final String workflowModuleId,
final String workflowModuleName,
final Resource[] bpmns,
final Resource[] dmns,
final Resource[] cmms)
Expand All @@ -67,8 +79,8 @@ protected void doDeployment(
.resumePreviousVersionsBy(ResumePreviousBy.RESUME_BY_DEPLOYMENT_NAME)
.enableDuplicateFiltering(true)
.source(applicationName)
.tenantId(workflowModuleId)
.name(workflowModuleId);
.tenantId(workflowModuleName)
.name(workflowModuleName);

boolean hasDeployables = false;

Expand All @@ -94,20 +106,32 @@ protected void doDeployment(
}

// BPMNs which are new will be parsed and wired as part of the deployment
final String deploymentId;
if (hasDeployables) {
deploymentBuilder.deploy();
deploymentId = deploymentBuilder
.deployWithResult()
.getId();
} else {
deploymentId = "";
}

// BPMNs which were deployTed in the past need to be forced to be parsed for wiring
// BPMNs which were deployed in the past need to be forced to be parsed for wiring
processEngine
.getRepositoryService()
.createProcessDefinitionQuery()
.tenantIdIn(workflowModuleId)
.tenantIdIn(workflowModuleName)
.list()
.stream()
.forEach(definition -> {
// process models parsed during deployment are cached and therefore
// not wired twice.
processEngine.getRepositoryService().getProcessModel(definition.getId());
try {
TaskWiringBpmnParseListener.setOldVersionBpmn(
!definition.getDeploymentId().equals(deploymentId));
processEngine.getRepositoryService().getProcessModel(definition.getId());
} finally {
TaskWiringBpmnParseListener.setOldVersionBpmn(false);
}
});

}
Expand Down
Loading

0 comments on commit fbeab7b

Please sign in to comment.