如何断开连接,然后使用 EasyNetQ 从 RabbitMQ 重新连接?
How to disconnect, then reconnect from RabbitMQ using EasyNetQ?
我处于需要断开与 RabbitMQ 的连接并使用 EasyNetQ 重新连接的情况。我正在按照文档中的描述处理 IBus。
https://github.com/EasyNetQ/EasyNetQ/wiki/connecting-to-rabbitmq
"To close the connection, simply dispose the bus ... This will close the connection, channels, consumers and all other resources used by EasyNetQ."
然而,当我调用创建新总线时,它仍然显示为已断开连接并已处理。
bus = RabbitHutch.CreateBus(connString);
bus.Dispose();
resolver.EasyNetQKernel.Release(bus);
bus = RabbitHutch.CreateBus(connString);
bus.Receive<Command>("CommandQueue"), Process);
此时,当我尝试重置我的消费者时,我收到一条 EasyNetQException 消息 "Bus has been disposed."
为什么我不能在处理后重新创建总线?
我没有使用过 Ninject,但是您可以尝试处理并重新创建整个 Ninject 容器而不是总线实例吗?我认为您的容器可能保留已处理的旧引用。
我处于需要断开与 RabbitMQ 的连接并使用 EasyNetQ 重新连接的情况。我正在按照文档中的描述处理 IBus。
https://github.com/EasyNetQ/EasyNetQ/wiki/connecting-to-rabbitmq
"To close the connection, simply dispose the bus ... This will close the connection, channels, consumers and all other resources used by EasyNetQ."
然而,当我调用创建新总线时,它仍然显示为已断开连接并已处理。
bus = RabbitHutch.CreateBus(connString);
bus.Dispose();
resolver.EasyNetQKernel.Release(bus);
bus = RabbitHutch.CreateBus(connString);
bus.Receive<Command>("CommandQueue"), Process);
此时,当我尝试重置我的消费者时,我收到一条 EasyNetQException 消息 "Bus has been disposed."
为什么我不能在处理后重新创建总线?
我没有使用过 Ninject,但是您可以尝试处理并重新创建整个 Ninject 容器而不是总线实例吗?我认为您的容器可能保留已处理的旧引用。