Unrecognized TaskExecutionListener implementation together with ApplicationRunner
My configuration: Spring Boot version: 2.7.3 Spring Cloud Dependencies version: 2021.0.3 Spring Cloud Task Core: 2.4.3 Spring Cloud Sleuth 3.1.3
I have spring component annotated with @Component something like this:
This class implements all three life cycle methods from TaskExecutionListener together with one from ApplicationRunner:
@Component
public final class TaskHandler implements ApplicationRunner, TaskExecutionListener {
...
}
When I run task application, run method is executed but nothing from TaskExecutionListener interface. Ive tried it also with annotation way (@BeforeTask, @AfterTask, @FailedTask)but same problem. My TaskHandler component is not foud and added to collection of registered listeners
What I found:
-
When debuging spring-cloud-task-core, concretely TaskLifecycleListener, I see that only one implementation exists in taskExecutionListenersFromContext variable: TraceTaskExecutionListener comming from sleuth library.
-
When I removed sleuth dependency, my TaskHandler component exists in taskExecutionListenersFromContext variable.
-
When I implement another dummy component MyClass implementing TaskExecutionListener, this listener is visible in taskExecutionListenersFromContext .
-
When returned back to older SB with following configuration: Spring Boot version: 2.5.9 Spring Cloud Dependencies version: 2020.0.5 Spring Cloud Task Core: 2.3.5 Spring Cloud Sleuth 3.0.5 everything works fine also with sleuth library. But in this case older sleuth library doesnt have TraceTaskExecutionListener so therefore it works.
Question: Can somebody help me where can be a problem? I would like to have one class implementing both interfaces because same data are shared between all methods in order to fill exitMessage for instance.
for this moment my temporary solution is disabled sleuth: spring.sleuth.task.enabled=false
thanks brpalo