-
Notifications
You must be signed in to change notification settings - Fork 41.2k
Ease the creation of multiple task executor and task scheduled builders #39928
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
Comments
Just FYI: we don't consider the auto-configurations public API (only their names), so something like this: return new TaskExecutionAutoConfiguration().taskExecutorBuilder( is absolutely not recommended. |
Thanks for the quick reply. Fully agree, it's an abusive usage of an internal API (just gave it as an "example"). |
We've had several issues in the past that are similar to this one, in that they express a desire to make it easier to create multiple beans of a given type without having to duplicate Spring Boot's auto-configuration code. #22403 and #35157 are examples. #21322 has been referenced as a possible solution for cases where the beans are connections to external services, but that would not apply to requirements like the one in this issue. So, this feels like a duplicate but I'm not sure any of the existing issues captures the general requirements. |
Thank you for your reply. I checked the other issues, the use case seems similar but not identical, and these issues are also quite old. It seems difficult to have a general approach that works in all cases. So, couldn't we try to apply the following approach: if a complex object can directly be built from a configuration properties class, wouldn't it make sense to expose a factory method on that class? Concrete example
Another approach might be to use a configurer or a customizer, but I'm not sure that's the best fit. |
We discussed this today and we think this is a general problem that we need to invest some time designing. The general pattern of creating an object from properties comes up again and again. |
Through an auto-configuration, Spring Boot makes it easy to create a task executor builder and a task scheduled builders with their respective sets of properties.
In most cases, this is sufficient, but in some specific cases, it may be necessary to create multiple builders with multiple sets of properties. In this case, the configuration has to be defined manually, resulting in some duplication of Spring Boot code.
It would be great if Spring Boot could provide an easy way to create these builders from a given property class.
Let's take a concrete example. Suppose an application needs to create 2 ThreadPoolTaskSchedulerBuilder with 2 sets of properties.
The support could be given as follows
xxx could either be a factory, a utility class or a static method on the property class itself.
Our use case is to create several builders in different contexts such as grpc, kafka, etc.
In previous versions of Spring boot, it was possible to abuse the use of auto-configurations as follows
Any feedback or comments are more than welcome.
The text was updated successfully, but these errors were encountered: