AnsweredAssumed Answered

Message Notification

Question asked by samsmith on Feb 29, 2016
Latest reply on Mar 1, 2016 by martin.grofcik

I have got a question on the following scenario:

Lets say that I have a BPM process that that has 2 steps:

'Human Task' followed by a 'Intermediate Catch Message Event'.

The below  code works perfectly fine if I notify the instance that  is already sitting in a 'Intermediate Catch Message Event'.
//Get the process instance Id from the <Business Key>
String processInstanceId=runtimeService.createProcessInstanceQuery().processInstanceBusinessKey("12345").singleResult().getId();
//Use the process instance id to get handle to  Execution object.
Execution execution=runtimeService.createExecutionQuery().processInstanceId(processInstanceId).
runtimeService.messageEventReceived("testCatchMessage", execution.getId());

This code fails with a NullPointerException (because the 'Execution' object it returned was null) when I try to notify the instance and it  is sitting in a <HUMAN TASK> and NOT  in the 'Intermediate Catch Message Event'.

Is this an expected behaviour? I would have thought that even in the second scenraio, when the instance is not sitting in a <Wait> state, the client code should not get an error and instead the instance should get notified as soon as the instance arrives in the 'Intermediate Catch Message Event' step.

Surely, this request should get QUEUED and the instance should be notified when it arrives at the <Wait> step.