我想问一下春季启动时流畅的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();
}
}
我不知道它是否正确。
答案 0 :(得分:1)
@PostConstruct为时尚早,您必须等到引擎设置并运行。使用camunda spring boot,您可以收听PostDeployEvent并使用它作为一个钩子:
@SpringBootApplication
@EnableProcessApplication
public class MyApp {
...
@EventListener
public void onStart(PostDeployEvent event) {
// deploy here
}
}