Can I signal a specific receive task?

cancel
Showing results for 
Search instead for 
Did you mean: 
avirankatz
Active Member

Can I signal a specific receive task?

Jump to solution

Hello,

I've read the following documentation regarding signaling an execution (in the user guide):

13.6.2. Execute an action on an execution

PUT runtime/executions/{executionId}
Table 90. Execute an action on an execution - URL parameters
ParameterRequiredValueDescription

executionId

Yes

String

The id of the execution to execute action on.

Request body (signal an execution):

1
2
3

{

  "action":"signal"

}

The above request works, but it doesn't signal a specific receive task? I'm looking for something like:

1
2
3
4

{

  "action":"signal",

  "receiveTaskId": "myReceiveTask"

}

I'm new to both activiti and BPMN, so if this question is regarded to bad understanding of CPMN principals, I would love a clarification.

Thanks in advance!

Aviran

1 Solution

Accepted Solutions
cjose
Senior Member II

Re: Can I signal a specific receive task?

Jump to solution

Since signals and messages can be used in a variety of ways, the signaling a signal on a receive task cannot work as you mentioned by "receiveTaskId": "myReceiveTask".

Signals are generally used for broadcasting. If you are looking to send a signal to a particular receive task using a boundary event I suggest using a message event. For better readability, name the message event something like "receive-task-message-event" which makes it look tied to your receive task . 

For completing the receive task it is a two step process, you will first need to query for active message subscriptions (executions) with name "receive-task-message-event" and get the execution id. Then complete the message subscription by executing the API

Hope this helps.

View solution in original post

4 Replies
avirankatz
Active Member

Re: Can I signal a specific receive task?

Jump to solution

Anyone?

cjose
Senior Member II

Re: Can I signal a specific receive task?

Jump to solution

Since signals and messages can be used in a variety of ways, the signaling a signal on a receive task cannot work as you mentioned by "receiveTaskId": "myReceiveTask".

Signals are generally used for broadcasting. If you are looking to send a signal to a particular receive task using a boundary event I suggest using a message event. For better readability, name the message event something like "receive-task-message-event" which makes it look tied to your receive task . 

For completing the receive task it is a two step process, you will first need to query for active message subscriptions (executions) with name "receive-task-message-event" and get the execution id. Then complete the message subscription by executing the API

Hope this helps.

avirankatz
Active Member

Re: Can I signal a specific receive task?

Jump to solution

Thank you for your answer. It helped indeed.

However, this triggered a different issue: we handle events from Activiti using an implementation of ActivitiEventListener. This works like a charm as process instances proceed from within Activiti Explorer or Activiti REST. But when I send a message via the API, events such as ACTIVITY_COMPLETED are not fired.

See the following code snippet:

public static void main(String[] args) {
    readProperties();
    processEngine = buildProcessEngine();
    processEngine.getRuntimeService().addEventListener(new ActivitiEventHandler("localhost", "61616"));
    new MessageSender(processEngine).sendMessage(args);
}

What am I missing here?

Aviran

avirankatz
Active Member

Re: Can I signal a specific receive task?

Jump to solution

In case anyone would come across the same problem -

This was a misunderstanding: I presumed that all events would show up in the ACT_EVT_LOG table, not knowing that there's a registered event listener that popoulates it. After not seeing the expected events in the table I thought that activiti doesn't dispatch them, when in reality they were dispatched but had no indication.

So I added the following line, which made activiti populate ACT_EVT_LOG:

runtimeService.addEventListener(new EventLogger(processEngine.getProcessEngineConfiguration().getClock()));