Multi Instance correlate from Message Rest API

Hi,

I am trying to use REST API to correlate a message. I have multi instance parallel sub process and not able to do it using the Rest API

From Sub Process here are different params

execution.getActivityInstanceId() -Activity_13wjnze:4aa49256-8a44-11ea-85ae-523eaae5604e
execution.getCurrentActivityId() -Activity_13wjnze
execution.getCurrentActivityName() -null
execution.getEventName() -null
execution.getParentId() -4aa46c39-8a44-11ea-85ae-523eaae5604e
execution.getProcessBusinessKey() -a704270c-894f-4b19-a215-d01a98687011
execution.getProcessDefinitionId() -SatTestProcessID:1:3d8dc433-89b8-11ea-be66-503eaae5604e
execution.getProcessInstanceId() -4aa3f6fa-8a44-11ea-85ae-523eaae5604e
execution.getId() -4aa46c43-8a44-11ea-85ae-523eaae5604e
execution.getBusinessKey() -a704270c-894f-4b19-a215-d01a98687011
assignee -cc58a9cf-a4bf-4ee0-9435-b7c16f4e6cba

http://localhost:8080/rest/message
My rest APi is
{
“messageName”: “Message_2l2e0ov”,

"businessKey": "a704270c-894f-4b19-a215-d01a98687011",
"correlationKeys": {
    "assignee": {
        "value": "af76ebb7-0099-4c38-964f-880fd82b2df4",
        "type": "String"
    }
}

}

I have attached the BPM and screen shot of the cockpit

I am contantaly getting the

"type": "RestException",
"message": "org.camunda.bpm.engine.MismatchingMessageCorrelationException: ENGINE-13031 Cannot correlate a message with name 'Message_2l2e0ov' to a single execution. 2 executions match the correlation keys: CorrelationSet [businessKey=a704270c-894f-4b19-a215-d01a98687011, processInstanceId=null, processDefinitionId=null, correlationKeys={\n  assignee => Untyped value 'af76ebb7-0099-4c38-964f-880fd82b2df4', isTransient = false\n}, localCorrelationKeys=null, tenantId=null, isTenantIdSet=false]"

Thanks,
SatyendraMultiTest.bpmn (5.3 KB) .

single instance is working fine without the correlation keys, but yes multi instance it’s just doesn’t know which to clear, so I have used the assignee variables to match but now able to make it working,
Your help is appreciated.
Thanks,
Satyendra

Hi @singhsattu,

if you check the shortend links in the Cockpit under Scope, you can see that they have different values (different scopes).

To use them for correlation, you should go for localCorrelationKeys in your request. (https://docs.camunda.org/manual/7.12/reference/rest/message/post-message/)

Hope this helps, Ingo

Hi @singhsattu you should define the input variable in your multi-instance receive task and set values either using expression or using cockpit.

Then you have to hit message rest api with localCorrelationKeys. Something like below.

{
“messageName”: “Message_2l2e0ov”,

"businessKey": "a704270c-894f-4b19-a215-d01a98687011",
 "localCorrelationKeys" : {
    "inputVar" : {"value" : "Test1", "type": "String"}
  }
}

Thanks an Regards,
Pradeep

Hi @Ingo_Richtsmeier,
Thank you very much for your reply, I have tried all possible combination to reach to the message in sub process.

I have 2 variables available assignee and sub and for both I have tried without any sucess
{
“messageName”: “Message_2l2e0ov”,
“businessKey”: “da30dbaf-d69c-4b50-a313-17e442a6d78d”,

"localCorrelationKeys ": {
    "sub": {
        "value": "a25528bc-4bae-4acf-a7f3-72f7b20949ab",
        "type": "String"
    }
},

"resultEnabled" : true

}

I received status code 400 and following is my response
{
“type”: “RestException”,
“message”: “org.camunda.bpm.engine.MismatchingMessageCorrelationException: ENGINE-13031 Cannot correlate a message with name ‘Message_2l2e0ov’ to a single execution. 2 executions match the correlation keys: CorrelationSet [businessKey=da30dbaf-d69c-4b50-a313-17e442a6d78d, processInstanceId=null, processDefinitionId=null, correlationKeys=null, localCorrelationKeys=null, tenantId=null, isTenantIdSet=false]”
}

Please suggest, what is wrong.

Hello Pradeep,
Than you so much for the reply, setting using cockpit is not possible, as in actual practicale world we have thousand of sub process in any given time. and setting using expression, not sure as this is receive task and I can’t find a way to do that and then we have API which triggers this receive message comes from outside, so there we won’t have this value for co-relate.

Thanks,
Satyendra

Hi @singhsattu Here I modified your bpmn file attached hereMultiTest (1).bpmn (5.5 KB) . I have used Input Variable in receive task and using expression I am setting values ( using assignee that you using it for multi-instance )

Then called api using rest.

{
  "messageName" : "Message_2l2e0ov",
   "localCorrelationKeys" : {
    "InputVar1" : {"value" : "Tata", "type": "String"}
  }
} 

Where “Tata” is the one of the assignee names that I used while instantiating process.

1 Like

Hello @pradeep.poojari

Thank you so much, this has worked. Beer is due from my side, shout to me when you are in Hyderabad, India.

@Ingo_Richtsmeier – Thank you so much for the help, The doc is not updated… when to clear the receive message when it is a part of the sub-process, if I am passing the combination of BusinessKey and message name it never worked, ideally which it should be working, and infact it was working in single process or if have just one sub process in queue.
Request you to please have the uniformity across any format of the process and which is in fact logical as well.
@DanielMeyer – Tagging you, as your youtube session was very helpful initially, please do look into the scenario to bring in the uniformity across the process, it helps.

Thanks all again.
Satyenra