Send Messages via REST API

1
0
-1

Hi,

in the process called "subProcess" I need to send a Message type "abortPayment" (via REST API) and automatically terminate with human task "Step 2". It is poossible?

JSON Body:

{

"messageName" : "abortPayment" ,

"targetProcess": "PagamentoAutomatico",

"messageContent" : {}

}

Diagram Here

Thanks,

Diana

1 answer

1
0
-1

Hello,

I checked your diagram, as soon as the subprocess is called the parallel gateway is triggered (you should use a start event before the gateway anyway).

The gateway will trigger in parallel both the step2 (Human) and step3 (with message).

So the step2 will already be activated, also if the message is not received.

If you want to trigger the step 2 only after the message is sent, you should move the step2 after the step3.

Out of topic, be careful with end events. In your diagrams you're using terminate end events for the subprocess, that terminate the process instance when reached. They are usually not a good idea when you use parallel gateways.

Hope it helps!

Cheers

Comments

Submitted by dianabento95 on Tue, 09/15/2020 - 17:55

This is what I want. I give an example: this is for payments. it has two options: or i execute "Step 2" or I sent a message (in future via Engine API) and the "Step 2" should be ignored. The ideia is to have Step 2 in my to do list but if de the sub process recieve a message the step 2 was "done" automatically. it is possible?

Submitted by enrico.curiotto on Tue, 09/15/2020 - 22:16

Yes it's possible, one way is to use a message boundary event on the task2 (Just drag and drop a catch message event on top of the step2). Without using a step3. You can manage the abort actions in the boundary event outgoing path.

Submitted by dianabento95 on Tue, 09/15/2020 - 22:56

I try something like this but it did't work. Diagram is here.

The body of the Rest API call:

{

"messageName" : "abortPayment" ,

"targetProcess": "EnviaMensagem"

}

Did I do something wrong?

Submitted by enrico.curiotto on Wed, 09/16/2020 - 00:21

At a first glance, you are missing message correlation.

When you say "it doesn't work" it's better if you add as much details as possible, like a stack trace.

You'll get have more chance to get an answer with value

Submitted by dianabento95 on Wed, 09/16/2020 - 01:11

if i was ar step 1 and send the message not pass to the outgoing transition. What it is have in message correlation ? processInstanceId?

Submitted by enrico.curiotto on Wed, 09/16/2020 - 08:58

the correlation key is a variable that should be known by both the processes (parent process and sub process). The processInstanceId of the parent can be passed to the child in the call activity, then it can be the correlation.

Submitted by dianabento95 on Wed, 09/16/2020 - 10:41

I create a correlation called processInstanceIdKey (script with processInstanceId). And I try to do the same process. In "Step 1" i send a message via Rest API and it has the same problem, staying in "Step 1" and not pass to the outgoing path ("Step 3").

Diagram here

Correlation here

Body of the Rest API call:

{

"messageName" : "abortPayment" ,

"targetProcess": "PagamentoAutomatico",

"messageContent" : {},

"correlations" : {

"processInstanceIdKey" : {

"value" : 13006,

"type" : "java.lang.Long"

}

}

}

Submitted by dianabento95 on Wed, 09/16/2020 - 10:51

Thanks for your help! I find the error...

Notifications