【发布时间】:2021-12-10 11:03:29
【问题描述】:
我们的应用程序可以非常快速地生成消息并需要 ACK。
这是一个愚蠢的模拟:
@Bean
public CachingConnectionFactory ccf() {
var ccf = new CachingConnectionFactory("localhost");
ccf.setPublisherConfirmType(CORRELATED);
ccf.setPublisherReturns(true);
return ccf;
}
@Bean
public ApplicationRunner run(RabbitTemplate template) {
return args -> {
for (int i = 1; i < 10001; i++) {
template.convertAndSend("poc", "hey");
if (i % 1000 == 0) {
LOG.info("{}", i);
} }
};
}
这段代码最终会创建和销毁多个频道,有没有办法限制将要同时创建的频道? (阻塞或入队)
这是在兔子控制台中保持缓存的通道之一:127.0.0.1:54190 (509)。
【问题讨论】: