How can I start a process and get response before arriving to wait state

cancel
Showing results for 
Search instead for 
Did you mean: 
maayanl
Active Member II

How can I start a process and get response before arriving to wait state

Hello,

I designed a very long and complex WF with up to 30 service tasks at the beginning and then user task.

When I run the WF through Activiti-Explorer the WF run just fine.

But, When I run the WF through Activiti-Rest, I get Internal server error 500.

This phenomenon happened again with WF that start with one service task that last for 3 min and after that there is user task.

I think the problem is that response for "start process" request is not given until WF reach wait state (user task for example) - the connection channel cut after a while without receiving the response.

Am I right?

I yes, How can I avoid it? How can I start a process and get response before arriving to wait state?

This is the request url I use:

http://localhost:1248/activiti-rest/service/runtime/process-instances/

Body:

{
"businessKey": "406401",
"processDefinitionId": "virusFound:29:147645",
"variables":
[
{
"name": "IncidentId",
"value": "406381"
},
{
"name": "IPHostName",
"value": "sdadas"
},
{
"name": "SuspiciousFilePath",
"value": "sadas"
},
{
"name": "mail",
"value": "svccyberapp@mnrlab.local"
}
]
}

Thanks,

Maayan

2 Replies
gdharley
Intermediate

Re: How can I start a process and get response before arriving to wait state

You should use a message start event rather than starting it in a regular fashion.

With the message start event, it is simply a fire and forget, the process will complete in it's own good time and you will get an immediate response.

So....

1. Change the model to use a message start event (it can be in addition to the regular start event if you want).

2. When calling from REST, use the URL:
POST http://<host>:<port>/service/runtime/process-instances


POST Payload:

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

Hope this helps,

Greg

maayanl
Active Member II

Re: How can I start a process and get response before arriving to wait state

Thanks Greg Harley‌ for the immediate response. Sorry for my delay...

I have problem with using the message start event because that mean defining every WF with 'message start event'. It has cost of complication in WF construction (WF construction is done by system users)

Another issue - I use this rest call (start process instance) also for 'errors handling'.

For now, I know how to catch errors occur in service tasks by two POST rest calls - complete task & start process.

Mean by the rest call of 'Start process' - I able to catch, in my system, errors occur in service tasks locating at the beginning of the process (before reaching wait state).

Strangely, I can not catch errors by 'ACTIVITY_ERROR_RECEIVED' event in Active MQ.

If I will use fire and forget I will cut this "errors stream" and that is not good...

Do you have any idea for my problems?

Thank you,

Maayan.