了解 DirectMessageListener 并发
Understanding DirectMessageListener concurrency
来自 Spring AMQP 参考文档,
With the DirectMessageListenerContainer, you need to ensure that the connection factory is configured with a task executor that had sufficient threads to support your desired concurrency across all listener containers that use that factory. The default pool size is only five.
However, there are some limitations with this approach, and certain features of the SMLC are not available with the DMLC. Also, concurrency is controlled by "consumersPerQueue" (and the client library’s thread pool).
假设我已经配置了一个带有自定义执行器的 CachingConnectionFactory(与 DirectMessageListenerContainer 关联),线程池大小为 20。
ExecutorService 固定池 = Executors.newFixedThreadPool(20);
并且,
客户端库的线程池设置为 ( 4 * 2 = 8),即 CPU 个内核数 = 4
并且,
我已经为我的 RabbitListener 配置了“consumersPerQueue=30”并发设置
我对究竟有多少并发消费者将处理来自队列的消息有点困惑?
一些关于这些设置 compliment/override 彼此真正有用的指导?
在 rabbitmq-users google 组 here 上讨论了 amqp-client 库中使用的各种执行器。
我不确定您所说的“客户端库的线程池”是哪个执行器,但具体来说,缓存连接工厂执行器服务已传入并用于调用消费者。由于它只有 20 个线程,这是您将达到的最大并发数。
来自 Spring AMQP 参考文档,
With the DirectMessageListenerContainer, you need to ensure that the connection factory is configured with a task executor that had sufficient threads to support your desired concurrency across all listener containers that use that factory. The default pool size is only five.
However, there are some limitations with this approach, and certain features of the SMLC are not available with the DMLC. Also, concurrency is controlled by "consumersPerQueue" (and the client library’s thread pool).
假设我已经配置了一个带有自定义执行器的 CachingConnectionFactory(与 DirectMessageListenerContainer 关联),线程池大小为 20。
ExecutorService 固定池 = Executors.newFixedThreadPool(20);
并且,
客户端库的线程池设置为 ( 4 * 2 = 8),即 CPU 个内核数 = 4
并且,
我已经为我的 RabbitListener 配置了“consumersPerQueue=30”并发设置
我对究竟有多少并发消费者将处理来自队列的消息有点困惑?
一些关于这些设置 compliment/override 彼此真正有用的指导?
在 rabbitmq-users google 组 here 上讨论了 amqp-client 库中使用的各种执行器。
我不确定您所说的“客户端库的线程池”是哪个执行器,但具体来说,缓存连接工厂执行器服务已传入并用于调用消费者。由于它只有 20 个线程,这是您将达到的最大并发数。