camunda - 在 spring 引导中部署 Fluent BPMN 模型 API
camunda - deployment fluent BPMN model API in spring boot
我想问一下在 spring 引导中使用流畅的 BPMN 模型 API 的 camunda 流程。
设置自动部署和重新部署(版本控制)的最佳做法是什么?
@Configuration
public class BpmProcess {
private final Log logger = LogFactory.getLog(getClass());
@Autowired
private ProcessEngine processEngine;
@Bean
public BpmnModelInstance bpmnModelInstance() {
BpmnModelInstance modelInstance = Bpmn.createExecutableProcess("esign-store")
.name("esign store document")
.startEvent("esign-startEvent")
.serviceTask("esign-uploadStorage")
.name("upload to storage")
.camundaAsyncBefore()
.camundaDelegateExpression("${uploadStorageDelegate}")
.serviceTask("esign-uploadCezar")
.name("upload to cezar")
.camundaAsyncBefore()
.camundaDelegateExpression("${uploadCezarDelegate}")
.endEvent("esign-endEvent")
.camundaAsyncBefore()
.messageEventDefinition("esign-endEventDefinition")
.done();
MessageEventDefinition event = modelInstance.getModelElementById("esign-endEventDefinition");
event.setCamundaDelegateExpression("${endReplyDelegate}");
Bpmn.writeModelToStream(System.out, modelInstance);
return modelInstance;
}
@PostConstruct
public void deploy(){
processEngine.getRepositoryService()
.createDeployment()
.addModelInstance("esign-store.bpmn", bpmnModelInstance())
.name("esign-store-service")
.deploy();
}
}
不知道对不对
@PostConstruct 太早了,你必须等到引擎设置好再运行。使用 camunda spring 启动,您可以收听 PostDeployEvent 并将其用作挂钩:
@SpringBootApplication
@EnableProcessApplication
public class MyApp {
...
@EventListener
public void onStart(PostDeployEvent event) {
// deploy here
}
}
我想问一下在 spring 引导中使用流畅的 BPMN 模型 API 的 camunda 流程。 设置自动部署和重新部署(版本控制)的最佳做法是什么?
@Configuration
public class BpmProcess {
private final Log logger = LogFactory.getLog(getClass());
@Autowired
private ProcessEngine processEngine;
@Bean
public BpmnModelInstance bpmnModelInstance() {
BpmnModelInstance modelInstance = Bpmn.createExecutableProcess("esign-store")
.name("esign store document")
.startEvent("esign-startEvent")
.serviceTask("esign-uploadStorage")
.name("upload to storage")
.camundaAsyncBefore()
.camundaDelegateExpression("${uploadStorageDelegate}")
.serviceTask("esign-uploadCezar")
.name("upload to cezar")
.camundaAsyncBefore()
.camundaDelegateExpression("${uploadCezarDelegate}")
.endEvent("esign-endEvent")
.camundaAsyncBefore()
.messageEventDefinition("esign-endEventDefinition")
.done();
MessageEventDefinition event = modelInstance.getModelElementById("esign-endEventDefinition");
event.setCamundaDelegateExpression("${endReplyDelegate}");
Bpmn.writeModelToStream(System.out, modelInstance);
return modelInstance;
}
@PostConstruct
public void deploy(){
processEngine.getRepositoryService()
.createDeployment()
.addModelInstance("esign-store.bpmn", bpmnModelInstance())
.name("esign-store-service")
.deploy();
}
}
不知道对不对
@PostConstruct 太早了,你必须等到引擎设置好再运行。使用 camunda spring 启动,您可以收听 PostDeployEvent 并将其用作挂钩:
@SpringBootApplication
@EnableProcessApplication
public class MyApp {
...
@EventListener
public void onStart(PostDeployEvent event) {
// deploy here
}
}