(For logging purposes,) I need to retrieve the (task) execution id inside a job execution in Spring Cloud Data Flow. In particular, I have access to several "job" objects (JobLauncher, JobExplorer, JobRepository, JobExecution
...), which don't seem to keep a correlation to the task. Moreover, something like @Value("{$spring.cloud.task.executionid:}")
doesn't seem to work.
You can use a Task Execution Listener.
You can let any bean implement TaskExecutionListener
(or use the annotations @BeforeTask
, @AfterTask
, @FailedTask
) and take the id from the TaskExecution
that is passed as argument to its methods.