adamsaghy commented on PR #5432: URL: https://github.com/apache/fineract/pull/5432#issuecomment-3883616440
> Hi @vidakovic, thanks for the review. > > I investigated using `spring.task.execution.*` as suggested. While those properties correctly auto-configure a TaskExecutor for `@Async` and related infrastructure, they don't fully address the requirement here for two reasons: > > **1. Synchronous by default** From the [Spring Boot docs](https://docs.spring.io/spring-boot/reference/features/task-execution-and-scheduling.html): > > > "The auto-configured AsyncTaskExecutor is used for: Execution of asynchronous tasks > > using @EnableAsync, Spring MVC, Spring WebFlux, Spring WebSocket, JPA bootstrap..." > > `SimpleApplicationEventMulticaster` is not in that list. Per the [Spring Framework JavaDoc](https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/context/event/SimpleApplicationEventMulticaster.html#setTaskExecutor(java.util.concurrent.Executor)): > > > "Default is equivalent to SyncTaskExecutor, executing all listeners synchronously > > in the calling thread." > > Unless `setTaskExecutor()` is explicitly called, event listeners run synchronously. > > **2. Security context propagation** Spring Boot's auto-configured executor is not wrapped with `DelegatingSecurityContextAsyncTaskExecutor`, nor is it associated with the event multicaster—both of which are required for correct async event handling in Fineract. > > Because of this, a properties-only solution isn't sufficient. That said, I'm happy to refactor the configuration to use Spring Boot's `ThreadPoolTaskExecutorBuilder`, so we can still honor the standard `spring.task.execution.*` pool sizing properties while explicitly wrapping the executor for security and wiring it into the multicaster. > > Does that approach work for you? Sounds right to me. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
