简体   繁体   English

Spring Cloud流中的BROKER rabbitMq关闭时如何处理?

[英]How to handle when the BROKER rabbitMq is down in Spring cloud stream?

我想了解我们该如何处理经纪人本身处于关闭状态的情况,这是RabbitMQ,我也不想尝试RETRY机制。相反,我想检查一下Spring Cloud流, 怎么回事?检测RabbitMQ是否关闭 ,根据这种情况,我需要推送消息。

@AutoWired
private CachingConnectionFactory connectionFactory;

Call connectionFactory.createConnection().close() to verify that the broker is up. 调用connectionFactory.createConnection().close()来验证代理是否已启动。 If it's not you'll catch an exception. 如果不是,您将捕获异常。

In general, this won't open a new connection, it will just check that the shared (or a cached) connection is available. 通常,这不会打开新的连接,只会检查共享(或缓存的)连接是否可用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM