I was hunting some knowledge on Camunda BPM during my free time. Then I came across this Event-based Gateway component which made my past two days difficult. Basically I was watching this tutorial in which the gentleman very nicely tells all the key components of Camunda BPM and how to execute them. Let me brief the tutorial based on keeping my query in mind.
So, I created a Camunda BPM workflow similar to the tutorial looking like below:
But at the Event-based Gateway component the gentleman executed the pending instance using REST Api with below details (more detail):
Content-type = application/json
method = POST
URI = http://localhost:8080/engine-rest/message
body = {"messageName" : "PaymentReceived","businessKey" : "4"}
Then I was going through Camunda docs where I found another component i.e. Receive Task. But as per documentation you can invoke an instance of Receive Task using below Java Code:
ProcessInstance pi = runtimeService.startProcessInstanceByKey("DefinationKey");
Execution execution = runtimeService.createExecutionQuery().processInstanceId(pi.getId()).activityId("ActivityId").singleResult();
runtimeService.signal(execution.getId());
But then out of curiosity I executed Rest API of Event-based Gateway on Receive Task and it worked without an issue. So, I was expecting vice versa should work, means execute an instance of Event-based Gateway using above code. But it did not.
So my question is, is invoking an instance of Event-based Gateway using Rest API is the only way or is there any alternate way which I missed from the document?