了解、替换、配置和修改 Spring Rabbit (AMQP) 线程池:问题列表
Understanding, replacing, configuring and modifying Spring Rabbit (AMQP) thread pools: A list of questions
我有几个关于 RabbitMQ + Spring 的简短问题,非常感谢你在这件事上的帮助。
阅读文档后
这里 (https://docs.spring.io/spring-amqp/reference/html/#connections)
此处 (https://www.rabbitmq.com/api-guide.html)
Java + Spring 客户端的 api 似乎有一个名为 CachingConnectionFactory.
的 class
事实:
CachingConnectionFactory 有两个感兴趣的成员:PublisherConnectionFactory 和 RabbitConnectionFactory
CachingConnectionFactory 扩展父 class 调用 AbstractConnectionFactory
CachingConnectionFactory 有一个名为 (ExecutorService channelsExecutor) 的成员。
AbstractConnectionFactory 有一个名为 (ExecutorService executorService) 的成员。
AbstractConnectionFactory 有一个名为 setExecutor(ExecutorService executorService) 的方法,它设置自己的 executorService 然后在它的 PublisherConnectionFactory
上调用相同的方法
RabbitConnectionFactory 有 4 (!) 个不同的执行器:sharedExecutor , shutdownExecutor, heartbeatExecutor, topologyRecoveryExecutor;它还有一个名为 nioParams 的成员,还有 另外 2 个执行器:nioExecutor 和 connectionShutdownExecutor。此外,它还有一个名为 params 的方法,接受另一个名为 consumerWorkServiceExecutor 的执行器。总共 7 个执行者 (!!)
似乎是 RabbitConnectionFactory,这里的文档(又是https://www.rabbitmq.com/api-guide.html),建议您可以在创建频道时传入任何自定义执行程序: rabbitConnectionFactory.newConnection(myExecutorService);
题目:
CachingConnectionFactory、PublisherConnectionFactory和RabbitConnectionFactory之间有什么区别和关系?
为什么我们需要这么多不同的执行程序池?它们之间有什么区别?
这些 classes 是否共享它们的线程池/执行器?
连接打开时,分配到哪个线程池?
通道打开时,分配到哪个线程池?
发布和消费操作使用不同的线程池吗?
如何传递我自己的执行器实现或以其他方式配置每个上述执行器?
merge/unify 部分或全部执行者是个好主意吗?
提前致谢
我刚刚在 rabbitmq-users
Google 群里回答了你。
我可以解决 Spring 个问题。
What is the difference, and the relationship, between CachingConnectionFactory, PublisherConnectionFactory and RabbitConnectionFactory?
CCF为主厂;默认。它的单个连接由所有组件共享(但它具有支持多个连接的缓存模式)。
PCF 是可选的 CCF,可用于发布(当 RabbitTemplate.usePublisherConnection
为真时)。建议这样做,让消费者在发布者被屏蔽的情况下继续消费。
CCF executorService(如果存在)被传递到 RCF.newConnection()。
channelsExecutor 是一个内部执行器,仅在发布者确认启用时使用;它用于延迟通道关闭请求,直到发布者确认到达(或超时)。
Why do we need so many different executor pools?
What is the difference between them all?
Do these classes share their thread pools / executors?
CCF executorService(如果存在)被传递到 RCF.newConnection()
。
When a connection is opened, to which thread pool is it allocated?
CCF executorService(如果存在)被传递到 RCF.newConnection()
。否则 amqp-client 使用它自己的执行器。
When a channel is opened, to which thread pool is it allocated?
Do publish and consume operations use different thread pools?
如果RabbitTemplate.usePublisherConnection
为真且PCF有不同的执行者。
How do I pass in my own executor implementation or otherwise configure, each of the aformentioned executors?
两个CCF执行器有setter个方法。
如果您想在 PCF 中使用不同的执行器,请使用 CCF.getPublisherConnectionFactory()
并调用其 setter.
Would it be a good idea to merge/unify some or all of the executors?
我有几个关于 RabbitMQ + Spring 的简短问题,非常感谢你在这件事上的帮助。
阅读文档后
这里 (https://docs.spring.io/spring-amqp/reference/html/#connections)
此处 (https://www.rabbitmq.com/api-guide.html)
Java + Spring 客户端的 api 似乎有一个名为 CachingConnectionFactory.
事实:
CachingConnectionFactory 有两个感兴趣的成员:PublisherConnectionFactory 和 RabbitConnectionFactory
CachingConnectionFactory 扩展父 class 调用 AbstractConnectionFactory
CachingConnectionFactory 有一个名为 (ExecutorService channelsExecutor) 的成员。
AbstractConnectionFactory 有一个名为 (ExecutorService executorService) 的成员。
AbstractConnectionFactory 有一个名为 setExecutor(ExecutorService executorService) 的方法,它设置自己的 executorService 然后在它的 PublisherConnectionFactory
上调用相同的方法
RabbitConnectionFactory 有 4 (!) 个不同的执行器:sharedExecutor , shutdownExecutor, heartbeatExecutor, topologyRecoveryExecutor;它还有一个名为 nioParams 的成员,还有 另外 2 个执行器:nioExecutor 和 connectionShutdownExecutor。此外,它还有一个名为 params 的方法,接受另一个名为 consumerWorkServiceExecutor 的执行器。总共 7 个执行者 (!!)
似乎是 RabbitConnectionFactory,这里的文档(又是https://www.rabbitmq.com/api-guide.html),建议您可以在创建频道时传入任何自定义执行程序: rabbitConnectionFactory.newConnection(myExecutorService);
题目:
CachingConnectionFactory、PublisherConnectionFactory和RabbitConnectionFactory之间有什么区别和关系?
为什么我们需要这么多不同的执行程序池?它们之间有什么区别?
这些 classes 是否共享它们的线程池/执行器?
连接打开时,分配到哪个线程池?
通道打开时,分配到哪个线程池?
发布和消费操作使用不同的线程池吗?
如何传递我自己的执行器实现或以其他方式配置每个上述执行器?
merge/unify 部分或全部执行者是个好主意吗?
提前致谢
我刚刚在 rabbitmq-users
Google 群里回答了你。
我可以解决 Spring 个问题。
What is the difference, and the relationship, between CachingConnectionFactory, PublisherConnectionFactory and RabbitConnectionFactory?
CCF为主厂;默认。它的单个连接由所有组件共享(但它具有支持多个连接的缓存模式)。
PCF 是可选的 CCF,可用于发布(当 RabbitTemplate.usePublisherConnection
为真时)。建议这样做,让消费者在发布者被屏蔽的情况下继续消费。
CCF executorService(如果存在)被传递到 RCF.newConnection()。 channelsExecutor 是一个内部执行器,仅在发布者确认启用时使用;它用于延迟通道关闭请求,直到发布者确认到达(或超时)。
Why do we need so many different executor pools? What is the difference between them all? Do these classes share their thread pools / executors?
CCF executorService(如果存在)被传递到 RCF.newConnection()
。
When a connection is opened, to which thread pool is it allocated?
CCF executorService(如果存在)被传递到 RCF.newConnection()
。否则 amqp-client 使用它自己的执行器。
When a channel is opened, to which thread pool is it allocated? Do publish and consume operations use different thread pools?
如果RabbitTemplate.usePublisherConnection
为真且PCF有不同的执行者。
How do I pass in my own executor implementation or otherwise configure, each of the aformentioned executors?
两个CCF执行器有setter个方法。
如果您想在 PCF 中使用不同的执行器,请使用 CCF.getPublisherConnectionFactory()
并调用其 setter.
Would it be a good idea to merge/unify some or all of the executors?