spring-cloud-task icon indicating copy to clipboard operation
spring-cloud-task copied to clipboard

Improve documentation on Batch - Task integration, especially regarding datasource and transactionManagers

Open nightswimmings opened this issue 1 year ago • 0 comments

Despite this and this, the outdated samples and the newer samples (later one seems to pass green because for some reason SimpleTaskAutoConfiguration is configuring the beans after JobConfiguration injections), I can't find a clear documentation on how we should combine Spring Batch and Spring Task at low level, which seems to be the scenario for the majority of user base, considering the issues section.

  • Is desirable that both Batch (BatchAutoconfiguration) and Task (SimpleTasAutoconfiguration) reuse same datasource and transactionmanager?
  • If no, which one should we use in JobConfiguration new API, that requires to pass transactionManager to create a tasklet or a chunklet?
  • If yes, why is DefaultTaskConfigurer creating a TransactionManager from the @Primary datasource regardless any potential @Primary transactionManager
  • Shouldn't the samples as defined right now fail on duplicate bean in JobConfiguration when trying to inject the @Primary transactionManager? In an scenario where defaults are provided, both DatasourceTransactionManager and SimpleTaskAutconfiguration expose a PlatformTransactionManager

The scenario gets even more tricky if the domain/logical part of the task also uses a database connection, so we need yet another datasource.

Thanks for all your amazing work so far, mates!!

nightswimmings avatar Jan 22 '24 16:01 nightswimmings