[英]Deploying dynamically created BPMN model using Activiti REST API
I am new to Activiti. 我是Activiti的新手。 I am working on a project in which i should be able to create process dynamically using spring mvc. 我正在一个项目中,我应该能够使用Spring MVC动态创建过程。 I have come acrossed http://stacktrace.be/blog/2013/03/dynamic-process-creation-and-deployment-in-100-lines/ 我遇到过http://stacktrace.be/blog/2013/03/dynamic-process-creation-and-deployment-in-100-lines/
Is it possible to deploy the dynamically created process using REST API directly or we should create bpmn-20.xml and deploy it. 是否可以直接使用REST API部署动态创建的过程,或者我们应该创建bpmn-20.xml并进行部署。 Also is there any example for creating complex process such as using boundary events dynamically. 也有用于创建复杂过程(例如动态使用边界事件)的任何示例。
Thanks 谢谢
It is possible through this endpoint /activiti-rest/service/deployment
! 可以通过此端点/activiti-rest/service/deployment
! Please check this forum thread for further infos + sample code. 请检查此论坛主题以获取更多信息和示例代码。
You do not have to really create the file on your disk, just simulate it with an InputStream of some sort: 您不必真正在磁盘上创建文件,只需使用某种InputStream模拟它即可:
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.addBinaryBody("deployment", new ByteArrayInputStream((<put-something-here>).toByteArray()), ContentType.DEFAULT_BINARY,"test.bpmn20.xml")
Here is the code for uploading .bpmn file content as string and starting the process at the same time: 这是用于将.bpmn文件内容作为字符串上传并同时启动该过程的代码:
@Autowired
private RuntimeService runtimeService;
@PostMapping("/deployAndStartProcess")
public void deployAndStartProcess(@RequestBody DeployWorkflow dw, @RequestParam(required = false) HashMap<String, Object> variables) {
String processXml = dw.getBpmnFile();
String processId = dw.getProcessKey();
ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
DeploymentBuilder deploymentBuilder = processEngine.getRepositoryService().createDeployment().name(processId);
deploymentBuilder.addString(processId + ".bpmn", processXml);
deploymentBuilder.deploy();
runtimeService.startProcessInstanceByKey(processId, variables);
}
Reference: Look at heymjo's answer in the last 参考:最后看heymjo的答案
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.