-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
PlatformTransactionManager bean is exposed unconditionally [BATCH-2788] #816
Comments
Michael Minella commented A few initial thoughts on this:
This feels like an easy thing for Boot to address without the need for Spring Batch to make the required breaking changes that would impact non Spring Boot users but I'm open to be convinced otherwise. |
Stéphane Nicoll commented This may have been phrased poorly but my report is not really related to Spring Boot per se. Exposing a
Considering that |
Michael Minella commented For Spring Batch, we require a compatible transaction manager so the idea that we'd allow someone to turn it off completely doesn't make sense IMHO. We already allow for facilities to customize which one you use, but those don't seem to be Boot friendly due to the ordering of operations in Boot. This leaves us with the following (that we've been able to come up with...we're open to other alternatives):
Any other mechanism Mahmoud and myself discussed means that we lose the ability to require a PlatformTransactionManager in a way that is both backwards compatible and maximizes the likelihood of compatibility. |
Stéphane Nicoll commented Thanks for the feedback.
This issue is about bean overriding and unconditional registration so hopefully nothing in my description lead to believe that I was asking to make this optional.
That's an interesting way to present the current situation. This issue is not about customization but about unconditional bean exposure. Let me give you a couple examples to illustrate how this has nothing to do with Spring Boot:
All in all, I think this statement is inaccurate. It's not about Spring Boot, it's not about ordering either. Regarding the solutions:
Spring Boot is already doing this
|
Michael Minella commented Ok...it looks like we have at least an idea of how to proceed. I'll keep you posted on what I see. |
Related/Similar issue: #838. |
With this issue in Sleuth (spring-cloud/spring-cloud-sleuth#1941) we've added support for instrumentation of |
This commit removes the unconditional exposure of the transaction manager as a bean in the application context. The transaction manager is still taken from the BatchConfigurer and set where needed (ie on JobRepository and StepBuilderFactory) as previously done, but is not exposed anymore as a bean to prevent any clash with a user defined transaction manager. If no transaction manager is provided, a DataSourceTransactionManager will be configured by default as required by batch (without being exposed as a bean). Issue spring-projects#816
This commit removes the unconditional exposure of the transaction manager as a bean in the application context. The transaction manager is still taken from the BatchConfigurer and set where needed (ie on JobRepository and StepBuilderFactory) as previously done, but is not exposed anymore as a bean to prevent any clash with a user defined transaction manager. If no transaction manager is provided, a DataSourceTransactionManager will be configured by default as required by batch (without being exposed as a bean). Issue spring-projects#816
This commit removes the unconditional exposure of the transaction manager as a bean in the application context. The transaction manager is still taken from the BatchConfigurer and set where needed (ie on JobRepository and StepBuilderFactory) as previously done, but is not exposed anymore as a bean to prevent any clash with a user defined transaction manager. If no transaction manager is provided, a DataSourceTransactionManager will be configured by default as required by batch (without being exposed as a bean). Issue spring-projects#816
Stéphane Nicoll opened BATCH-2788 and commented
While this can't be changed easily as it will break backward compatibility, Spring Batch should not expose a
PlatformTransactionManager
unconditionally (see SimpleBatchConfiguration).Spring Boot 2.1 has a mode enabled by default that throws an exception on startup if a bean is overridden. If a user defines its own transaction manager with Spring Batch, they will have to disable the flag as the application will fail. This isn't really expected as Spring Boot is supposed to handle and detect such scenario.
Arguably, Spring Boot should provide whatever
PlatformTransactionManager
and Spring Batch should be configured to use this. We can't implement this mode at the moment as Spring Batch exposes aPlatformTransactionManager
itself.This problem has been raised in several places (i.e. BATCH-2294). IMO, the resolution is incorrect: this is not about customizing the transaction manager to use, this is about exposing a bean in the context that may not be Spring Batch's responsibility in the first place. Besides, it is very likely that the transaction manager instance the user provides via the
BatchConfigurer
is already a bean so exposing it again feels wrong in the first place.Affects: 4.1.1
The text was updated successfully, but these errors were encountered: