How can I correlate the message to the running camunda process from the API which is called explicitly

Viewed 1033

I am running a camunda process and waiting for an event to occur. I need to trigger the message from a different API which is not part of the process.

Please let me know how can I correlate the message to the running camunda process from the API which is called explicitly.

2 Answers

There are no restrictions on from where to correlate a Message.

You can for example correlate via the businessKey.

Here an example with the fluent API:

runtimeService.createMessageCorrelation("orderCancelled")
      .processInstanceBusinessKey("someOrderId")
      .setVariable("CANCEL_REASON", "someReason")
      .setVariable("CANCEL_TIMESTAMP", new Date())
      .correlate();

This is taken from Fluent API for Message Correlation

Or check out the Rest-API that is described here:

https://docs.camunda.org/manual/7.16/reference/rest/message/post-message/

I am able to resolve the issue, the camunda process which is running is a sub process and I dint add business key expression to the sub process, because of wich it is not able to correlate with my business key.

When I added the business key to sub process it resolves the issue for me.

Related