Hi,
I’m currently using Axon Framework with Spring Boot, and I’m looking to configure several Pooled Streaming Event Processors (PSEP) to share a common thread pool. According to the reference guide, this should be possible:
Thread Pool Configuration - The tracking processor does not allow sharing a thread pool between different instances. For the pooled streaming processor, a
ScheduledExecutorService
is configurable, which allows sharing the executor between different processor instances. Thus, the PSEP provides a higher level of flexibility towards optimizing the total amount of threads used within an application. The freedom in thread pool configuration is helpful when, for example, the number of different Event Processors in a single application increases.
(Source: Axon Framework Reference Guide - Thread Configuration)
However, I couldn’t find specific instructions on how to configure a shared thread pool. By default, it seems that a separate thread pool is created for each processor.
I attempted to use EventProcessingConfigurer::registerPooledStreamingEventProcessorConfiguration
to register a shared workerExecutor
, but it didn’t seem to have the desired effect. Here’s the code snippet I used:
@Autowired
public void configure(EventProcessingConfigurer processingConfigurer,
@Qualifier("sharedWorkerExecutor") ScheduledExecutorService sharedWorkerExecutor) {
processingConfigurer.registerPooledStreamingEventProcessorConfiguration(
(configuration, builder) -> builder.workerExecutor(sharedWorkerExecutor)
);
}
Despite this configuration, each processor still appears to create its own thread pool. I suspect that the issue might be due to the default configuration in AxonAutoConfiguration::configureEventHandling
, where a new ScheduledExecutorService
is created:
AxonAutoConfiguration.java#L325
Could you please advise if there is a preferred way to configure a shared thread pool for multiple Pooled Streaming Event Processors?
Thank you!