Is Boundary Signal Event even support for Service Task?

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Member II

Is Boundary Signal Event even support for Service Task?

Hey experts - I am new to Activiti and recently hitting a problem in trying to stop an active process.  The reason of doing that is a breakglass handling when a service task is stuck in execution.

We tried to attach a boundary signal event to our Service process, but then on calling signalEventReceived, nothing happens, and the task is not killed (proven by some log dump to the process itself).

Is Boundary event even support for service task?

<signal id="sForceTerminate" name="sForceTerminateName" activiti:scope="global"></signal>
<message id="ElocateRequest" name="ElocateRequest"></message>
<process id="ElocateRequestProcess" isExecutable="true">
<startEvent id="AmpsMessageReceived" name="Elocate Request">
<messageEventDefinition messageRef="ElocateRequest"></messageEventDefinition>
</startEvent>
<serviceTask id="CreateElocateRequest" name="Create elocate request" activiti:async="true" activiti:expression="${messageConverter.convertRequestToObject(execution)}"></serviceTask>
<sequenceFlow id="IsElocateRequest" sourceRef="AmpsMessageReceived" targetRef="CreateElocateRequest"></sequenceFlow>
<sequenceFlow id="sid-05EF09EE-83F6-43F9-A367-34BC52E0AF2B" sourceRef="ForceTerminateEvent" targetRef="sid-D21BB7B8-BC83-46F2-BE23-DE4759CA732E"></sequenceFlow>
<boundaryEvent id="ForceTerminateEvent" attachedToRef="CreateElocateRequest" cancelActivity="true">
<signalEventDefinition signalRef="sForceTerminate"></signalEventDefinition>
</boundaryEvent>
<serviceTask id="sid-D21BB7B8-BC83-46F2-BE23-DE4759CA732E" name="Post Termination Processing" activiti:expression="${postHandler.execute(execution)}"></serviceTask>
<endEvent id="sid-696F0901-FC92-4F3C-A832-31C1898DAE41"></endEvent>
<sequenceFlow id="sid-E4852BD7-56DD-4E71-AE18-F6A75EBEF6CE" sourceRef="CreateElocateRequest" targetRef="sid-696F0901-FC92-4F3C-A832-31C1898DAE41"></sequenceFlow>
<sequenceFlow id="sid-55466468-EAC3-4B01-87D9-F52BABEE5094" sourceRef="sid-D21BB7B8-BC83-46F2-BE23-DE4759CA732E" targetRef="sid-696F0901-FC92-4F3C-A832-31C1898DAE41"></sequenceFlow>
</process>

5 Replies
Highlighted
Intermediate

Re: Is Boundary Signal Event even support for Service Task?

Scenarios may be hard to come by, but it is a valid BPMN construct.

Greg

bp3‌

Highlighted
Member II

Re: Is Boundary Signal Event even support for Service Task?

what does that mean?

Highlighted
Intermediate

Re: Is Boundary Signal Event even support for Service Task?

My apologies, I did not see the scenario in your original question, only the heading.

Boundary event on service tasks are certainly supported (I use error events all the time) but I have never tested message or signal boundary events.

Will try to take a look at this some time in the net few days.

Greg

Highlighted
Intermediate

Re: Is Boundary Signal Event even support for Service Task?

Without know the internals of your implementation class, it appears as though you are using a delegateExpression (${messageConverter.convertRequestToObject(execution)}) to implement your service call.

Looking at the source, the ServiceTaskExpressionActivityBehavior class does not implement the signallable interface and as such does not implement "wait" state characteristics that are required for timer, message and signal boundary event handling.

I recommend you reimplement using a signallable activiti behavior where the "leave" method is explicitly called explicitly. You're implementing class needs to act in an asynchronous manner.

The following blog post provides reasonable guidance, there are also unit tests in the build:

How to create a custom activity 

There is also a good description of this pattern on the Camunda site here:

camunda-bpm-examples/servicetask/service-invocation-asynchronous at master · camunda/camunda-bpm-exa... 

Greg

#bp3

Highlighted
Member II

Re: Is Boundary Signal Event even support for Service Task?

Thanks alots Greg, will try that out and post the result