如何使用REST API在Activiti中启动工作流程 [英] How to initiate a workflow in Activiti using REST API

查看:576
本文介绍了如何使用REST API在Activiti中启动工作流程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用带有Eclipse的服务任务等创建了一个Activit流程,并将.bar部署到了在tomcat上运行的Activiti。它已成功部署,我可以使用activiti-explorer启动我的过程,而不会出现任何问题。部署的流程名称为我的流程,它也在Activiti-Explorer中的流程->部署的流程定义下列出。在图中,它的名称为 myProcess:1:1473

I have created a Activit Process using Service Tasks etc with eclipse and deployed the .bar to Activiti which is running on tomcat. It was successfully deployed I can start my process using activiti-explorer without any issue. The deployed process name is "My process" and it is listed under Processes->Deployed Process Definitions in the Activiti-Explorer as well. In the diagram it has the name "myProcess:1:1473"

但是我有两个问题。

  • I need to start my process using REST call. (i.e. Without using Activiti-explorer) . What is the URL for that? I tried several variations of (http://localhost:8080/activiti-rest/service/runtime/process-instances) but none of them working.
  • When I restart the tomcat my process instance is not shown in the Activit -explorer. Each time I restart I need to redeploy the process .bar file. Is that the natural behavior of the engine?

推荐答案


  • 对于第一个问题,请查看本指南以获取更多详细信息:

    • For your first question check this guide for further details:


      POST运行时/流程实例应该是您的端点(一定要进行 POST 请求,并以 application / json 作为您的内容类型)

      POST runtime/process-instances should be your endpoint (Be sure to make a POST request, with application/jsonas your content type)

      另一方面,应对有效负载进行格式化在以下三个模板之一中:

      The payload on the other hand should be formatted in one of three templates:

      请求正文(按流程定义ID开头):

      {
      processDefinitionId: oneTaskProcess:1:158,
      businessKey: myBusinessKey,
      variables:[
      {
      name: myVar,
      value:这是一个变量,
      }
      ]
      }

      请求正文(以流程定义键开头):

      {
      processDefinitionKey: oneTaskProcess,
      businessKey: myBusinessKey,
      tenantId: tenant1,
      变量:[
      {
      name: myVar,
      value:这是一个变量 ,
      }
      ]
      }

      请求正文(按消息开头):

      {
      message: newOrderMessage,
      businessKey: myBusinessKey,
      tenantId: tenant1,
      变量:[
      {
      name: myVar,
      value:这是一个变量,
      }
      ]
      }


    • 至于第二个问题,您应该意识到,OOTB(即用型)配置可能会在每次重新启动时涉及自动DB清理,您需要找到该配置并使用您选择的值覆盖它!检查此部分以获取更多信息, databaseSchemaUpdate 参数可能正好您正在寻找什么!

    • As for your second issue, you should be aware that the OOTB (Out Of The Box) config may involve automatic DB cleaning upon each and every restart, you need to locate that config and override it with values of your choice! Check this section for further info, the databaseSchemaUpdate param might be exactly what you are looking for!

      这篇关于如何使用REST API在Activiti中启动工作流程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆