Affects: 5.2.5
Currently @Transactional annotation supports only hard-coded values for the timeout attribute. Sometimes it might be necessary for a project to externalize the timeout value via configuration (for instance, to have a quick way to increase the timeout on a critical business operation without the code changes and keep business running).
There are examples of configurable values already implemented. @Scheduled supports fixedDelay / fixedDelayString, fixedRate / fixedRateString, etc.
Would you be interested in this functionality? We could prepare a pull request supporting timeoutString in @Transactional.
Comment From: jhoeller
Good point, those timeout values could easily be placeholders like in @Scheduled. We added transaction labels for 5.3 already (see #24890), let's also add timeoutString in the same timeframe.
Unfortunately it might not be as straightforward as in the scheduling support. We might need some internal reworking here due to the multiple abstraction levels behind transaction annotation processing, and the need to access the embedded value resolver from the container.
Since I need to review our recent transaction labels contribution anyway, I'll have a look at timeout resolution in the same pass. From that perspective, unless you are in the process of preparing a pull request already, I'm also happy to pick this up for a first pass myself.
Please note that embedded value resolution usually happens at configuration time. The use of a placeholder facilitates a potential change of the value... but only on restart of the application. I hope this is sufficient for the purposes that you have in mind.
Comment From: orange-buffalo
Thank you for the quick reply. Yes, restarting the application to apply this kind of configuration changes seems to be a reasonable measure.
We haven't started preparing the PR yet, so will not collide with your changes. If at any time there is anything we can help with, please let us know.
Comment From: jhoeller
Alright, I'll look at it from our usual embedded value resolution perspective then. Not too hard to carry an EmbeddedValueResolver through to the inner annotation parser, or to preserve an original String value up until an EmbeddedValueResolver is available at an outer level. Being at it, I might introduce placeholder support for our new transaction labels as well.
Thanks for the suggestion, and thanks for your willingness to contribute... much appreciated!
Comment From: jhoeller
I've pushed a first cut to master, introducing a resolvable timeout attribute on @Transactional as well as <tx:method>. Placeholders get resolved in timeoutString, qualifier and labels now.
Feel free to give it a try in the upcoming 5.3 snapshot...
Comment From: orange-buffalo
Tested it on the snapshot version, works like a charm. Many thanks for such a fast feature implementation!