Element Template format for Execution Listener with Java Class

I am trying to use an element template and I am having trouble determining the correct JSON syntax when configuring an execution Listener with a Java Class.

I have tried:

{
“name”: “PUB Notifications”,
“id”: “com.bp3.examples.NotificationListener”,
“appliesTo”: [
“bpmn:UserTask”
],
“properties”: [
{
“type”: “Hidden”,
“value”: “com.bp3.examples.Notifications”,
“binding”: {
“type”: “camunda:executionListener”,
“event”: “start”,
“isClass”: true
}
}
],
“entriesVisible”: {
“_all”: true
}
}

And I have tried:

{
“name”: “PUB Notifications”,
“id”: “com.bp3.examples.NotificationListener”,
“appliesTo”: [
“bpmn:UserTask”
],
“properties”: [
{
“type”: “Hidden”,
“binding”: {
“type”: “camunda:executionListener”,
“event”: “start”,
“class”: “com.bp3.examples.InitNotifications”
}
}
],
“entriesVisible”: {
“_all”: true
}
}

Neither format appears to work.
I can not find an example in github either and there don’t appear to be answers to similar questions on the forum.

What is the correct format for this?

Ultimately I want a BPMN element that looks like:
<camunda:executionListener class=“com.bp3.foo” event=“start” />

Thanks,
Greg

Ok, so I looked into the modeler source, seems execution listener with anything other than a script are not currently available.
The question now becomes, when will this be available?

Scenario:
I want to add a set of listeners to specific user tasks but I don’t want the process designer/developer (semi technical) to have to remember which combinations of listeners go together. I want to use Element Templates to group these listeners together so the developer only needs to select the associated template to their function, the listeners would be added automatically.

Thanks,
Greg

Your observation is correct, we do not support templating Java classes as Execution Listeners right now.

I’ve opened this feature request in the Camunda Modeler project.

Thanks Nikku,

I checked out the feature request, this is exactly what I am after.

Greg

Hello, is there some implementation progress? Or do you have some workaround how to fill Class field?

Thanks!

Finally I found solution, it’s not nice but I don’t have to modify Camunda Modeler:

For Java Delegate:

{    
    "value": "new com.yourcompany.CustomJavaDelegateClass().execute(execution)",
        "type": "Hidden",
        "binding": {
        "type": "camunda:executionListener",
            "event": "start",
            "scriptFormat": "groovy"
    }
}

For Execution Listener:

{    
    "value": "new com.yourcompany.CustomExecutionListenerClass().notify(execution)",
        "type": "Hidden",
        "binding": {
        "type": "camunda:executionListener",
            "event": "start",
            "scriptFormat": "groovy"
    }
}

The script simply creates a new instance of custom JavaDelegate/ExecutionListener class and executes it with current execution instance (see article about available script variables). And it works exactly same like “class” listener type then.

I hope that it will help to someone :wink:

1 Like

@JanTichava thanks for sharing

If you are looking for even further customizations, here is something i was working on yesterday that gives you access to the Fluent API builder when you deploy: Ability to edit BpmnModelInstance before bpmn parse listener?. You can configure your activities with element templates that save Camunda Properties (the extension tab in modeler). and then you detect those properties and edit with the fluent api. as reusable objects.