Spring Cloud Task-Batch - taskBatchDao.saveRelationship doesn't write data

90 Views Asked by At

I have a small spring-bach application and deploy it locally in scdf. It works fine so far, taskexecutions run and the metadata tables are filled. Except for one - TASK_TASK_BATCH! I see the log output of the TaskBatchExecutionListener with "The job execution [id] was run within the task execution [id]" but no records are written by taskBatchDao.saveRelationship. So I wrote my own JobListener and wrote the records myself via a repository in a transaction to which I explicitly assign the transaction manager of the metadatasource. But this cannot be the solution. Thanks in advance

1

There are 1 best solutions below

2
Henning On

You need to expose your Job as a bean. Then the TaskBatchExecutionListenerBeanPostProcessor will add the TaskBatchExecutionListener as a job listener to your job.

For all other features of Spring Batch or Spring Cloud Task, it is not necessary that each job is a bean. But if it's not, you'll need to add the TaskBatchExecutionListener to the jobs yourself.

If you have the artifact spring-cloud-task-batch on the classpath, and use the annotation @EnableTask, then your application context contains a TaskBatchExecutionListener bean that you can autowire.