How to initiate a workflow in Activiti using REST

2019-04-16 20:14发布

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"

But I have two questions.

  • 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?

1条回答
在下西门庆
2楼-- · 2019-04-16 20:14
  • For your first question check this guide for further details:

    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:

    Request body (start by process definition id):

    { "processDefinitionId":"oneTaskProcess:1:158", "businessKey":"myBusinessKey", "variables": [ { "name":"myVar", "value":"This is a variable", } ] }

    Request body (start by process definition key):

    { "processDefinitionKey":"oneTaskProcess", "businessKey":"myBusinessKey", "tenantId": "tenant1", "variables": [ { "name":"myVar", "value":"This is a variable", } ] }

    Request body (start by message):

    { "message":"newOrderMessage", "businessKey":"myBusinessKey", "tenantId": "tenant1", "variables": [ { "name":"myVar", "value":"This is a variable", } ] }

  • 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!

查看更多
登录 后发表回答