# Triggerable CMMN Service Task

**URL:** https://forum.flowable.org/t/triggerable-cmmn-service-task/5992
**Category:** Flowable Engine
**Created:** [May 10, 2020, 9:46pm UTC](https://forum.flowable.org/t/triggerable-cmmn-service-task/5992 "2020-05-10T21:46:43Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![vanrogu](https://avatars.discourse-cdn.com/v4/letter/v/8edcca/32.png) [@vanrogu](https://forum.flowable.org/u/vanrogu)
#### Post date: [May 10, 2020, 9:46pm UTC](https://forum.flowable.org/t/triggerable-cmmn-service-task/5992/1 "2020-05-10T21:46:43Z")

</div>

Hi,

Is there a CMMN equivalent of the “triggerable” servicetask feature in BPMN?  
Use case would be to schedule some asynchronous (long-running) action when the plan item instance becomes ACTIVE, and to COMPLETE it via an API call when the answer comes in.

CmmnRuntimeService has a method for “triggerPlanItemInstance”, but the behavior class linked to a custom java delegate PlanItem does not implement CmmnTriggerableActivityBehavior…

---

<div class="post-metadata">

### Author: ![joram](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/joram/32/26_2.png) [@joram](https://forum.flowable.org/u/joram)
#### Post date: [May 18, 2020, 8:01pm UTC](https://forum.flowable.org/t/triggerable-cmmn-service-task/5992/2 "2020-05-18T20:01:06Z")

</div>

The default delegate doesn’t expose that method, but the `org.flowable.cmmn.engine.impl.behavior.CmmnTriggerableActivityBehavior` interface does. Many of the default behaviors actually implement that interface, because in CMMN most of the plan items need to complete after executing the behavior.

---

<div class="post-metadata">

### Author: ![vanrogu](https://avatars.discourse-cdn.com/v4/letter/v/8edcca/32.png) [@vanrogu](https://forum.flowable.org/u/vanrogu)
#### Post date: [May 19, 2020, 5:32am UTC](https://forum.flowable.org/t/triggerable-cmmn-service-task/5992/3 "2020-05-19T05:32:10Z")

</div>

Hi Joram,  
Thanks for your reply! I had identified this interface, but am confused on how to link this behavior to a custom ServiceTask. If I implement a servicetask by implementing the PlanItemJavaDelegate, how can one specify the behavior to be CmmnTriggerableAcvitiyBehavior? Unless I’m mistaken, the behavior interface is not to be implemented upon the servicetask itself, is it?

If I trace through the Flowable engine code, I see a triggerable behavior being applied to UserTask etc… but my custom servicetask always ends up with non-triggerable behavior.

---

<div class="post-metadata">

### Author: ![joram](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/joram/32/26_2.png) [@joram](https://forum.flowable.org/u/joram)
#### Post date: [May 26, 2020, 7:15pm UTC](https://forum.flowable.org/t/triggerable-cmmn-service-task/5992/4 "2020-05-26T19:15:30Z")

</div>

Sorry, I missed your response. If you implement the CmmnTriggerableAcvitiyBehavior interface and use it instead the PlanItemJavaDelegate, the engine will pick it up.

> [@vanrogu](#):
>
> If I trace through the Flowable engine code, I see a triggerable behavior being applied to UserTask etc… but my custom servicetask always ends up with non-triggerable behavior.

Indeed, the behaviors with wait state (like the user task) use this. But I assume you’ve tried this by setting it in the class attribute of the service task? Do you have an example that we can try?

---

<div class="post-metadata">

### Author: ![vanrogu](https://avatars.discourse-cdn.com/v4/letter/v/8edcca/32.png) [@vanrogu](https://forum.flowable.org/u/vanrogu)
#### Post date: [May 28, 2020, 8:23am UTC](https://forum.flowable.org/t/triggerable-cmmn-service-task/5992/5 "2020-05-28T08:23:46Z")

</div>

Hi Joram,

I’m still missing the point I’m afraid.

- If I implement only the **CmmnTriggerableActivityBehavior** on the service task class, the deployment fails:  
_FlowableException: Delegate expression ${testDelegate} did neither resolve to an implementation of interface org.flowable.cmmn.engine.impl.behavior.PlanItemActivityBehavior nor interface org.flowable.cmmn.api.delegate.PlanItemJavaDelegate_

- If I also implement the **PlanItemJavaDelegate** or **PlanItemActivityBehavior** interface, the original exception occures when I “trigger” the task:  
_FlowableException: Cannot trigger a plan item which activity behavior does not implement the interface org.flowable.cmmn.engine.impl.behavior.CmmnTriggerableActivityBehavior interface_

Just to be 100% sure: I’m simply implementing these interfaces on the custom delegate class itself, right?  
Like this:

public class TestDelegate implements CmmnTriggerableActivityBehavior {

```
@Override
public void trigger(DelegatePlanItemInstance planItemInstance) {
	System.err.println("trigger");
}

@Override
public void execute(DelegatePlanItemInstance delegatePlanItemInstance) {
	System.err.println("execute");
}

```

}

I’m still thinking this is related to a Delegate implementation class vs its attached Behaviour class. I would expect the CmmnTriggerableActivityBehavior interface on the behaviour class, not on the delegate class itself, or am I wrong?

---

<div class="post-metadata">

### Author: ![joram](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/joram/32/26_2.png) [@joram](https://forum.flowable.org/u/joram)
#### Post date: [June 1, 2020, 9:57am UTC](https://forum.flowable.org/t/triggerable-cmmn-service-task/5992/6 "2020-06-01T09:57:29Z")

</div>

It looks like you are correct. I assumed that the javadoc on [flowable-engine/modules/flowable-cmmn-api/src/main/java/org/flowable/cmmn/api/delegate/PlanItemJavaDelegate.java at main · flowable/flowable-engine · GitHub](https://github.com/flowable/flowable-engine/blob/master/modules/flowable-cmmn-api/src/main/java/org/flowable/cmmn/api/delegate/PlanItemJavaDelegate.java#L19) was correct, but it isn’t.

Fixed it here: [Cmmn: fix plan item java delegate trigger not possible · flowable/flowable-engine@65bd7ab · GitHub](https://github.com/flowable/flowable-engine/commit/65bd7ab6150417d8b52c6c70639450a0ed221dda)

> [@vanrogu](#):
>
> I’m still thinking this is related to a Delegate implementation class vs its attached Behaviour class. I would expect the CmmnTriggerableActivityBehavior interface on the behaviour class, not on the delegate class itself, or am I wrong?

Correct. The behaviour class didn’t implement the interface that implements the trigger method. Hence, it never passes it through to the actual delegate.

---

<div class="post-metadata">

### Author: ![vanrogu](https://avatars.discourse-cdn.com/v4/letter/v/8edcca/32.png) [@vanrogu](https://forum.flowable.org/u/vanrogu)
#### Post date: [June 3, 2020, 8:11pm UTC](https://forum.flowable.org/t/triggerable-cmmn-service-task/5992/7 "2020-06-03T20:11:50Z")

</div>

Hi Joram,  
Works like a charm - thanks a lot!  
regards  
Günther
