-
Notifications
You must be signed in to change notification settings - Fork 41.5k
Support externalized properties for spring transaction manager #7561
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
Support externalized properties for spring transaction manager #7561
Conversation
7f25105
to
68b7274
Compare
👍 for this proposal. However I think it should also affect |
* default-timeout * rollbac-on-commit-failure
68b7274
to
e8e032f
Compare
Hi @vpavic , thanks for your comment ! |
Add Spring TransactionManager properties to allow timeout and rollback settings to be configured. See gh-7561
…ties-on-tx * pr/7561: Polish spring transaction manager properties Support spring transaction manager properties
@kazuki43zoo Thanks for the PR. I've reworked things a bit in commit 99e7266 if you'd like to review. The main change that I've made is to make Thanks again for the contribution! |
There is no need for |
Add a `TransactionManagerCustomizer` callback interface that can be used to customize auto-configured `PlatformTransactionManagers`. Also update `...transaction.*` properties under a single unified `spring.transaction...` key since the existing auto-configurations would often share a transaction manager (the technology specific transaction managers are `@ConditionalOnMissingBean` and may use a manager created by a previous auto-configuration). See gh-7561
@philwebb looks sensible. I've polished minor things in 4b641ca. The only thing that bugs me at this point is that Not sure that we need to act on it though because that would make things a bit more complicated. |
@snicoll Yeah the order of auto-configuration bugged me as well. Actually, I should check that it's not caused a package tangle. |
Hi @philwebb, I've tried 1.5.0.BUILD-SNAPSHOT. I found an one issue on creating a customizer using lambda expression as follow: @Bean
PlatformTransactionManagerCustomizer<JtaTransactionManager> transactionManagerCustomizer() {
return transactionManager -> {
System.out.println("jta");
System.out.println(transactionManager.getDefaultTimeout());
};
} Above code is fail at the start up time. I've enabled the
As alternative, I've created a customizer class instead of lambda expression as follow: @Component
static class MyJtaTransactionManagerCustomizer implements PlatformTransactionManagerCustomizer<JtaTransactionManager> {
@Override
public void customize(JtaTransactionManager transactionManager) {
System.out.println("jta");
System.out.println(transactionManager.getDefaultTimeout());
}
} It work fine (it can be skip a customization). Is this behavior work as design ? or bug ? or limitation ? |
@kazuki43zoo This is an unfortunate limitation of using a lambda See SPR-12525 for some discussion. We might, however, be able to use a similar trick to that discussed in SPR-14109. |
@philwebb Thanks for good information !! |
Update `TransactionManagerCustomizers` to deal directly with `ClassCastExceptions` assuming that they are because a customizer is implemented using a lambda. See gh-7561
I will submit a feature request that support externalized properties for spring transaction manager. In this request, following properties are supported.
true
because the Oracle perform implicit commit when close a connection)e.g. )
What do you think about this request ?