cancel
Showing results for 
Search instead for 
Did you mean: 

Message Notification

samsmith
Champ in-the-making
Champ in-the-making
Hi,

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'.
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
//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).
                        messageEventSubscriptionName("testCatchMessage").singleResult();
      
runtimeService.messageEventReceived("testCatchMessage", execution.getId());
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx


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.
1 REPLY 1

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi Sam,

Is this an expected behaviour?
yes

You can implement queueing by yourself if you want to have something like that. The question is when the events should be re-thrown from the queue again (are they still valid?).

Regards
Martin