-
Notifications
You must be signed in to change notification settings - Fork 38.3k
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
Document how to configure the ApplicationEventMulticaster
used by the ApplicationContext
#29996
Comments
SimpleApplicationEventMulticaster
cannot set Executor
in application event
SimpleApplicationEventMulticaster
cannot set Executor
in application eventExecutor
in SimpleApplicationEventMulticaster
If you want to configure the Thus to change the Although this is partially documented in the class-level Javadoc for |
Thanks for your reply. But why not support autowire Executor while initApplicationEventMulticaster Best Regards |
Hi @YJFinBJ, I don't think it is very common for people to customize the I was merely explaining how one could do that.
Having re-read your initial questions, yes, I think configuring individual listeners explicitly as Rationale:
In other words, it's a choice between global asynchronous publication vs. selective asynchronous consumption. In any case, we can still improve the documentation for configuring the |
Executor
in SimpleApplicationEventMulticaster
ApplicationEventMulticaster
used by the ApplicationContext
ApplicationEventMulticaster
used by the ApplicationContext
ApplicationEventMulticaster
used by the ApplicationContext
Hi @sbrannen , I agree with your opinion for Best Regards |
I've added some explicit hints for setting up a custom "applicationEventMulticaster" bean definition to the reference documentation, typically for asynchronous event processing by default and/or for custom handling of listener exceptions. At Spring Framework level, |
initApplicationEventMulticaster()
inAbstractApplicationContext
creates a newSimpleApplicationEventMulticaster
instance and registers it in the container, but theExecutor
in it is alwaysnull
because there is no autowiring for it.Code as below:
spring-framework/spring-context/src/main/java/org/springframework/context/event/SimpleApplicationEventMulticaster.java
Lines 135 to 146 in f60bec9
So, when it runs it always steps into the
else
clause. I would like to ask if I want to invoke listener async, must I use@Async
?Although
@Async
can work because of dynamic proxy technique.Or, must I manually set an async
Executor
in theSimpleApplicationEventMulticaster
instance?I feel puzzled for the code above.
Best Regards
The text was updated successfully, but these errors were encountered: