cancel
Showing results for 
Search instead for 
Did you mean: 

How to send specific signal to receive tasks?

jhahn
Champ in-the-making
Champ in-the-making
Hello,

I have two receive tasks, called task1 and task2.
I arrive at task1 and I have multiple services that could potentially send a signal to the executionId of task1.

How do I limit the receiveTask so that it proceeds only when it receives a certain eventName?
I couldn't find any example in the REST API.

Getting the executionId is no problem as I can query by activityId (task1, task2). I'm just worried that if 2 services attempt to signal for task1, it will double signal thus close task1 AND task2.

7 REPLIES 7

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi,

Signals are broadcasts. I would use messages - I would use them instead.
exampleSmiley Surprisedrg.activiti.engine.test.bpmn.event.message.MessageIntermediateEventTest

Regards
Martin

jhahn
Champ in-the-making
Champ in-the-making
Is this not supported in the REST API?

trademak
Star Contributor
Star Contributor
Yes, the REST API also provides support for signal and message events. Receive tasks can't be coupled to a message or signal event however. You need to use an intermediate catch event for that purpose.

Best regards,

jhahn
Champ in-the-making
Champ in-the-making
But I need to have a timer on the task to escalate.

I need to do something like this.
http://blog.goodelearning.com/wp-content/uploads/2014/05/diagram-3.jpg

So for the "Waiting for response", I want it to wait until a message called "responseReturned" gets sent to the process instance.

So you're saying receive task doesn't support the ability to complete the task for a specific messageName only?
I see "Message Ref" property on intermediate message event, which is what I think I need.

If impossible, I guess I could use User Task for this purpose and just assign the owner to the "system"…

I'm relatively new to bpmn/activiti so I apologize if this is all trivial knowledge…

trademak
Star Contributor
Star Contributor
Ah ok, that wasn't clear to me. Yes you can attach a boundary message event to a receive task.
In the user guide this points to the correct REST API service to call to invoke the boundary message event:

15.6.2. Execute an action on an execution

PUT runtime/executions/{executionId}

Best regards,

jhahn
Champ in-the-making
Champ in-the-making
Ok, so now I attached the boundary message event to a receive task. However, this pattern FEELS wrong…
http://i.imgur.com/DYbooAl.png

Anyway, it still won't recognize the message and throw the error

Execution with id '10684728' does not have a subscription to a message event with name 'thingFinished'

Do I need to subscribe this receive task to a message event? If that functionality exists, I probably don't need the message boundary event?

Maybe I'm not understanding the purpose of receive task correctly…

jbarrez
Star Contributor
Star Contributor
The receive task waits, does nothing until you call runtimeService.signal(executionID).

Now, this is pretty confusing, cause it has NOTHING to do with a BPMN signal event (that's signalEventReceived, rather).

So either you call the API directly, on receiving the message (eg on a JMS queue or whatever), or you have a message event, in that case you will need to call the void messageEventReceived(String messageName, String executionId); method.