Reputation: 341
I have the following problem:
There is a message start event lets say message name is MessageX
followed by a Task.
If i send a POST request engine-rest/message
with the body
{
"messageName" : "MessageX",
"processInstanceId" : "null",
"resultEnabled" : "true"
}
i get the answer
{
"resultType": "ProcessDefinition",
"execution": null,
"processInstance": {
...
"id": "1234-567-8910",
...
}
}
So there is now a process with id 1234-567-8910
started and waiting on the Task. Fine.
I now want to corellate the same message to the Process Instance with the id 1234-567-8910
like so:
{
"messageName" : "MessageX",
"processInstanceId" : "1234-567-8910",
"resultEnabled" : "true"
}
The BPMN looks like this:
I expect that he says something like process 1234-567-8910 is not waiting for message
or something, but instead he starts a new process instance...
Is there a way to only corellate the message when the process is actually at some point where he is actually waiting for it?
Upvotes: 1
Views: 2840
Reputation: 1558
You can do this in KIE(jbpm). There the start and others nodes are signals and there is an api for those. It also accepts process variables as parameters.
Upvotes: 0
Reputation: 46
Messages only can be correlated when the execution token is waiting at the message event. In your case, execution token is already handed over to the task, so correlation fails and a new instance is spawned.
But why do you want to sent the same message twice? Starting an instance with a message already delivered it. You could separate process start and message delivery by using an explicit start request (needs to separate start-event and message-event in your process-definition):
POST localhost:8080/engine-rest/process-definition/key/<your-process-id>/start HTTP/1.1
{
"variables": {
"someVar": {
"value": "hello", "type":"string"
}
},
"businessKey" : "1234"
}
and afterwards:
POST localhost:8080/engine-rest/message HTTP/1.1
{
"messageName" : "MessageX",
"businessKey" : "1234",
"processVariables" : {
"someNewVar" : {"value" : 5, "type": "Integer"}
}
}
For sure you could also use p-id to correlate, but do you really want to keep track of all these id's?
KR, Joachim
Upvotes: 1