Skip to content

Configure Batch with the auto-configured PlatformTransactionManager #32330

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wilkinsona opened this issue Sep 14, 2022 · 1 comment
Closed
Assignees
Labels
type: enhancement A general enhancement
Milestone

Comments

@wilkinsona
Copy link
Member

In Batch 5, its PlatformTransactionManager is no longer a bean. This hopefully makes it possible for us to configure Batch to use the auto-configuration transaction manager rather than creating a Batch-specific transaction manager as we currently do. This is complicated by @BatchDataSource. If a user configures a Batch-specific DataSource, we will need to ensure that the transaction manager that Batch is configured to use is using the same DataSource. This may be broken in 2.7 at the moment when JPA and @BatchDataSource are used together. I believe this can result in Batch using a JpaPlatformTransactionManager that's backed by the default entity manager factory and DataSource while using its own Batch-specific DataSource.

@wilkinsona wilkinsona added the type: enhancement A general enhancement label Sep 14, 2022
@wilkinsona wilkinsona added this to the 3.0.x milestone Sep 14, 2022
@wilkinsona wilkinsona added status: pending-design-work Needs design work before any code can be developed and removed status: pending-design-work Needs design work before any code can be developed labels Sep 14, 2022
@wilkinsona
Copy link
Member Author

I discussed this today with @fmbenhassine and the expectation on the Batch side is that the user ensures that the DataSource and PlatformTransactionManager beans are aligned. We can adapt Boot's auto-config to the latest changes in Batch to continue to honour @BatchDataSource and use the auto-configured transaction manager. If the user has a more complex setup and they need to take control, they can use @EnableBatchProcessing or a DefaultBatchConfiguration sub-class to take control. In either case, Boot's auto-configuration will now back off.

Note that @EnableBatchProcessing causing the auto-configuration to back off is a breaking change. In 2.x, this annotation was required to enable Boot's auto-configuration. With the recent changes in Batch we can change this to align with other areas, such as Spring MVC and WebFlux where @EnableWebMvc or @EnableWebFlux causes the respective auto-configuration to back off.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

1 participant