-1

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: enter image description here 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?

Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140

1 Answers1

0

Answer:

This is a lame query, because I am trying to execute instances of Event-based Gateway instead of Payment Confirmed component as shown in image.

Below is the screen shot which enlighten the idea in more details: enter image description here

So the code snippet required to move the instance from Payment Confirmed is as below

List<MessageCorrelationResult> results = runtimeService.createMessageCorrelation("PaymentReceived").correlateAllWithResult();
results.stream().forEach(result->{System.err.println(result.getExecution().getId());});
Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140