-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't run call-activities asynchronously
- Loading branch information
1 parent
68df160
commit 5a8b9dc
Showing
6 changed files
with
185 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
...ot/src/main/java/io/vanillabp/camunda7/service/jobs/startprocess/StartProcessCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package io.vanillabp.camunda7.service.jobs.startprocess; | ||
|
||
import org.camunda.bpm.engine.impl.interceptor.Command; | ||
import org.camunda.bpm.engine.impl.interceptor.CommandContext; | ||
import org.camunda.bpm.engine.impl.persistence.entity.MessageEntity; | ||
|
||
public class StartProcessCommand implements Command<String> { | ||
|
||
static final String TYPE = "VBP_StartProcess"; | ||
|
||
private final StartProcessJobHandlerConfiguration configuration; | ||
|
||
public StartProcessCommand( | ||
final String workflowModuleId, | ||
final String bpmnProcessId, | ||
final String businessKey) { | ||
|
||
this.configuration = new StartProcessJobHandlerConfiguration( | ||
workflowModuleId, | ||
bpmnProcessId, | ||
businessKey); | ||
|
||
} | ||
|
||
@Override | ||
public String execute( | ||
final CommandContext commandContext) { | ||
|
||
final var entity = new MessageEntity(); | ||
|
||
entity.init(commandContext); | ||
entity.setJobHandlerType(TYPE); | ||
entity.setJobHandlerConfiguration(configuration); | ||
|
||
commandContext.getJobManager().send(entity); | ||
|
||
return entity.getId(); | ||
|
||
} | ||
|
||
} |
63 changes: 63 additions & 0 deletions
63
...src/main/java/io/vanillabp/camunda7/service/jobs/startprocess/StartProcessJobHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package io.vanillabp.camunda7.service.jobs.startprocess; | ||
|
||
import org.camunda.bpm.engine.impl.interceptor.CommandContext; | ||
import org.camunda.bpm.engine.impl.jobexecutor.JobHandler; | ||
import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity; | ||
import org.camunda.bpm.engine.impl.persistence.entity.JobEntity; | ||
|
||
import java.util.regex.Pattern; | ||
|
||
public class StartProcessJobHandler implements JobHandler<StartProcessJobHandlerConfiguration> { | ||
|
||
private static final Pattern SPLITTER = Pattern.compile("([^\n]+)\n([^\n]+)\n(.*)"); | ||
|
||
@Override | ||
public String getType() { | ||
return StartProcessCommand.TYPE; | ||
} | ||
|
||
@Override | ||
public void execute( | ||
final StartProcessJobHandlerConfiguration configuration, | ||
final ExecutionEntity execution, | ||
final CommandContext commandContext, | ||
final String tenantId) { | ||
|
||
commandContext | ||
.getProcessEngineConfiguration() | ||
.getProcessEngine() | ||
.getRuntimeService() | ||
.createProcessInstanceByKey(configuration.getBpmnProcessId()) | ||
.businessKey(configuration.getBusinessKey()) | ||
.processDefinitionTenantId(configuration.getWorkflowModuleId()) | ||
.execute(); | ||
|
||
} | ||
|
||
@Override | ||
public StartProcessJobHandlerConfiguration newConfiguration( | ||
final String canonicalString) { | ||
|
||
if (canonicalString == null) { | ||
return null; | ||
} | ||
|
||
final var splitter = SPLITTER.matcher(canonicalString); | ||
if (!splitter.matches()) { | ||
return null; | ||
} | ||
|
||
return new StartProcessJobHandlerConfiguration( | ||
splitter.group(1), | ||
splitter.group(2), | ||
splitter.group(3)); | ||
|
||
} | ||
|
||
@Override | ||
public void onDelete( | ||
final StartProcessJobHandlerConfiguration configuration, | ||
final JobEntity jobEntity) { | ||
// nothing to do | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
.../io/vanillabp/camunda7/service/jobs/startprocess/StartProcessJobHandlerConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package io.vanillabp.camunda7.service.jobs.startprocess; | ||
|
||
import org.camunda.bpm.engine.impl.jobexecutor.JobHandlerConfiguration; | ||
|
||
public class StartProcessJobHandlerConfiguration implements JobHandlerConfiguration { | ||
|
||
private final String businessKey; | ||
|
||
private final String workflowModuleId; | ||
|
||
private final String bpmnProcessId; | ||
|
||
public StartProcessJobHandlerConfiguration( | ||
final String workflowModuleId, | ||
final String bpmnProcessId, | ||
final String businessKey) { | ||
|
||
this.businessKey = businessKey; | ||
this.workflowModuleId = workflowModuleId; | ||
this.bpmnProcessId = bpmnProcessId; | ||
|
||
} | ||
|
||
@Override | ||
public String toCanonicalString() { | ||
|
||
return workflowModuleId + "\n" + bpmnProcessId + "\n" + businessKey; | ||
|
||
} | ||
|
||
public String getWorkflowModuleId() { | ||
return workflowModuleId; | ||
} | ||
|
||
public String getBpmnProcessId() { | ||
return bpmnProcessId; | ||
} | ||
|
||
public String getBusinessKey() { | ||
return businessKey; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters