cancel
Showing results for 
Search instead for 
Did you mean: 

Getting null value while calling Message catching event

dhayanidhypazha
Champ in-the-making
Champ in-the-making
Hi,

AS per the client request, we need to insert values to multiple tables in the same flow (more than 10 tables) so I created multiple service tasks- one for each table, Inorder to handle db issue i added error boundary event on each service task and calling a call activity (fault handling process) to handle the exception, once the error has been handled the call needs to go back to the same service task from where the issue occured - again to complete the insertion of values into the table. Inoreder to handle that scenario i created a sequence flow from service task to call activity and vice versa. Since multiple service tasks came into picture, the flow started looking confused so client asked me to go for different approach, so I created sequence flow from service task to call activity  (fault handling process) and in call activity i created a java class with method to call back the service task through Message catching event and i added message catching event( intermediate event ) in the flow and created a sequence flow between message catching event and service task. But when i try to make a call from call activity to message catching event I am getting null exception. All the scenario exists in the same flow. Please find below the code I wrote to call message catching event.

public void Task6(DelegateExecution execution)throws Exception
{
   try
   {
      System.out.println("Error boundary call");
      EngineServices engineServices  = execution.getEngineServices();
      RuntimeService runtimeService = engineServices.getRuntimeService();
      Execution messageExecution = runtimeService.createExecutionQuery().processInstanceId(execution.getProcessInstanceId()).messageEventSubscriptionName("MessageCatchEvent").singleResult();
       System.out.println("messageExecution "+messageExecution ); —-> This returning null
      runtimeService.messageEventReceived("MessageCatchEvent", messageExecution .getId() );
}
catch(Exception e)
{
e.printstacktrace();
}
}

+++++++System.out.println("messageExecution "+messageExecution );+++++ —-> This returning null

and the name of the message catching event is "MessageCatchEvent".
Please help me out in fixing the issue.

Thanks and Regards
Dhayanidhy P.

4 REPLIES 4

jbarrez
Star Contributor
Star Contributor
I'm not sure that messages will work through a call activity (I don't even think it is valid BPMN 2.0).

And embedded subprocess will work, but that won't solve your problem probably.

dhayanidhypazha
Champ in-the-making
Champ in-the-making
Hi ,

Is it possible to add boundary and Intermediate events to call activity? I hope we can add error boundary event and timer event other than that any other event is possible? Because when i try to call message boundary event of call activity from call activity, I m getting null.
If it is possible to call, then plz share some reference document it will be very much helpful for me.

jbarrez
Star Contributor
Star Contributor
Timers will work, but passing data using events is not something that will work.
The right BPMN 2.0 way to do it, is to have multiple processes in one definition file and define message exchange between them. However, that is unfortunately not implemented in Activiti.

You could, however, create a similar behavipur using custom service tasks and receive tasks to continue/halt processes based on messages.

dhayanidhypazha
Champ in-the-making
Champ in-the-making
Thanks a lot Jorambarrez for your update.