Hooks in camunda

Hi,
I want to do some processing before and after a process execution in camunda. So is there a way to do so, I mean is there any hooks or listeners available.

Hi @sunnyorange,

You can have a look at the Delegation code page in our User guide:
https://docs.camunda.org/manual/latest/user-guide/process-engine/delegation-code/#execution-listener

1 Like

Hi @Yana
I have tried that example but when I’m using let’s say something as provided in the example

<process id="executionListenersProcess">
    <extensionElements>
      <camunda:executionListener
          event="start"
          class="org.camunda.bpm.examples.bpmn.executionlistener.ExampleExecutionListenerOne" />
    </extensionElements>

I’m getting The prefix “camunda” for element “camunda:executionListener” is not bound.

You have to add xmlns:camunda="http://camunda.org/schema/1.0/bpmn" namespace.
https://docs.camunda.org/manual/7.11/reference/bpmn20/custom-extensions/extension-elements/
Or you can use the Modeler (link) and it’ll be added for you when you add the listener through the Properties Panel.

1 Like

Hi @Yana

I tried above solution it helps but when I’m deploying my application getting following errors –

ENGINE-08043 Exception while performing ‘Deployment of Process Application application’ => ‘Parse processes.xml deployment descriptor files.’: ENGINE-09005 Could not parse BPMN process. Errors:

My Process.xml looks like this

<process-application
xmlns="http://www.camunda.org/schema/1.0/ProcessApplication"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:camunda="http://camunda.org/schema/1.0/bpmn">

<process id="executionListenersProcess">
	<extensionElements>
		<camunda:executionListener event="start"
			class="com.welcome.listener.MyProcessExecutionListener" />
	</extensionElements>
</process>

Hi @sunnyorange,

the examples of Listeners that @Yana provided to you need to be placed in your process files (the .bpmn-files where you define your BPMN-process). Do not add these Listeners to the processes.xml file of your project. This class is there for different reasons.

If you want to execute some logic when your process starts or ends, add an ExecutionListener to the start- or end-event of your process.

The content of a .bpmn-file with a Listener added to the start-event will loke like this:

<?xml version="1.0" encoding="UTF-8"?>

<bpmn:definitions …>
<bpmn:process id=“Process_1” isExecutable=“true”>
<bpmn:startEvent id=“StartEvent_1”>
<bpmn:extensionElements >
<camunda:executionListener class=“com.hello” event=“start” />
</bpmn:extensionElements>
</bpmn:startEvent>

Hope that helps.

Regards
Michael

1 Like