Calling global TaskListener in spring boot camunda project

Hi, I am trying to call global tasklistener in spring boot starter project where we are using @EnableProcessApplication.below is the code .

@SpringBootApplication
@ProcessApplication
@ApplicationPath("/")
public class CamundaStarterApplication extends SpringBootProcessApplication{

public static void main(String[] args) {
    SpringApplication.run(CamundaStarterApplication.class, args);
}

@Override
public TaskListener getTaskListener() {
	return new TaskListener() {
		public void notify(DelegateTask delegateTask) {

			System.out.println("test start...");

};
}

I am starting the spring boot project and starting the process which is creating new task as well but
it expected to print test Start…once task is created but this is not printing on the console.
please help me on this.

1 Like

Hey @abhi1o3,

did you have a look at the documentation on the Spring Eventing Bridge?

Hope that helps.

Best,
Tobias

1 Like

I tried to implement this Spring Eventing Bridge but it did not work. below the code.

@ProcessApplication
@ApplicationPath("/")
@Component
public class CamundaStarterApplication extends SpringBootProcessApplication{

public static void main(String[] args) {
    SpringApplication.run(CamundaStarterApplication.class, args);
}

@EventListener
public void onTaskEvent(DelegateTask delegateTask) {
	
	System.out.println("test start...");

}

does this need any kind of configuration on bpmn side?

No config needed on BPMN side.
If I hook up your event listener in the simple example, all works fine.

So I suggest something in your setup is not working.
Which version of the starter are you using?
Can you see something like the following in your log when you start your application?

INFO 2576 --- [  restartedMain] o.c.b.s.b.s.event.EventPublisherPlugin   : EVENTING-001: Initialized Camunda Spring Boot Eventing Engine Plugin.
INFO 2576 --- [  restartedMain] o.c.b.s.b.s.event.EventPublisherPlugin   : EVENTING-003: Task events will be published as Spring Events.
INFO 2576 --- [  restartedMain] o.c.b.s.b.s.event.EventPublisherPlugin   : EVENTING-005: Execution events will be published as Spring Events.
INFO 2576 --- [  restartedMain] o.c.b.s.b.s.event.EventPublisherPlugin   : EVENTING-007: History events will be published as Spring events.

If not, then the event publisher plugin is not enabled.
Please make sure that you haven’t set the following properties to false in your application.yaml

camunda.bpm.eventing.execution=true
camunda.bpm.eventing.history=true
camunda.bpm.eventing.task=true

Hope you find any leads to your issue with this.

If you like, you can also share your setup and code in a more extensive matter so people here can have a closer look to spot the error.

Best,
Tobias