cancel
Showing results for 
Search instead for 
Did you mean: 

Receive Task does not subscribe and receive message event

andrey_nikolov
Champ in-the-making
Champ in-the-making
I have a process which defines a 'message' event

<message id="Task_Message" name="Task Message"/>

and includes a ReceiveTask to receive that particular message

<receiveTask id="Receive_Balance_Message" name="Receive Balance Message" messageRef="Task_Message"/>


When the process starts and eventually reaches the ReceiveTask node, with new entry created in ACT_RU_EXECUTION table as expected.

However, the event subscription (correlation to message name) is not established, with ACT_RU_EVENT_SUBSCR table remaining empty.

When we we try to post the message, the event subscription query returns no active subscribers for that message, and the process ever advances past the receive task.

List<Execution> executions = runtimeService.createExecutionQuery().messageEventSubscriptionName("Task Message").list();
for (Execution execution : executions) {
   runtimeService.messageEventReceived("Task Message", execution.getId()));
}


Does Activiti 5.21 fully implement ReceiveTask functionality? What could be the reason that the message correlation is not established?

The user guide mentions "currently we have only implemented Java semantics for this task" but suggests messages can be received nevertheless. If that is still the case, could we expect message events are implemented in Activiti 6.0?

Please advise!
2 REPLIES 2

warper
Star Contributor
Star Contributor
Hi Andrey!
ReceiveTask is not intended to receive messages by subscription, it merely persists process and waits for any signal on its execution.
Take a look at "8.5.10. Java Receive Task" section in activiti user guide:

ProcessInstance pi = runtimeService.startProcessInstanceByKey("receiveTask");
Execution execution = runtimeService.createExecutionQuery()
  .processInstanceId(pi.getId())
  .activityId("waitState")
  .singleResult();
assertNotNull(execution);

runtimeService.signal(execution.getId());

If you want to send signal/message through subscription, you need either signalCatchingEvent or messageCatchingEvent.

gdharley
Elite Collaborator
Elite Collaborator

Hey Andrey,

Warper has provided a good technical explanation, but I wanted to add a little more "colour" to your questions below....

<snip>

Does Activiti 5.21 fully implement ReceiveTask functionality? What could be the reason that the message correlation is not established?

The user guide mentions "currently we have only implemented Java semantics for this task" but suggests messages can be received nevertheless. If that is still the case, could we expect message events are implemented in Activiti 6.0?

</snip>


Activiti (5 and 6) rely on a message framework injecting messages into the workflow engine. We have done this using message driven beans when running on a J2EE app server, or more easily using Camel or Mule.

The easiest way (IMO) to tie activiti into a JMS, ActiveMQ, email or other messaging system is to use the available camel (or mule) service tasks.

If you want to use the generic receive message, you will need to have a class "signal" the execution :

runtimeService.signal(execution.getId());

In order to let it proceed.

Hope this helps,
Greg