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 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'.
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
//Get the process instance Id from the
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());
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

This code fails with a NullPointerException (because the 'Execution' object it returned was null) when I try to notify the instance that 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 but instead the instance should get notified as soon as the instance arrives at 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.
6 REPLIES 6

sankalpn
Champ in-the-making
Champ in-the-making
runtimeService.createExecutionQuery().processInstanceId(processInstanceId) will return ExecutionQuery. You have to do .singleResult().get() on it to retrieve execution.

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi Sam,

It is expected behaviour.
Queueing -> You can implement it by  your own.

In the case when you fire an event to the relevant execution which is not listening on this event, nothing happens.

Regards
Martin

mariocmp
Champ in-the-making
Champ in-the-making
I'm facing a problem with message events.
After start the main process, while waiting for Task1 to complete, a message was received and subprocess started. When subprocess ends, a message is thrown to start subprocess event (SubEvent1). After SubEvent2 is completed a message is thrown and the Task4 has to catch the event and ends the main process.

Is that possible with Activiti 5.17.0???

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi Mario,

I would say that your question is not related to the thread topic.
The answer is yes.

Regards
Martin

samsmith
Champ in-the-making
Champ in-the-making
Thanks Martin.
Is there any plan to add this QUEUING mechanism into the notification service anytime soon. I am from the Oracle BPM background and it has a in-built QUEUEING mechanism where the Event stays in the Queue until the execution arrives at the Notification Wait step and then it notifies it automatically.

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi Sam,

I do not have such a plan.
If you have such a need, you can implement it by yourselves and create pull request. Anybody from the team will provide you support.

Regards
Martin