官术网_书友最值得收藏!

Canceling subscriptions

All the subscribe methods return an ISubscriptionResult. It contains properties that describe the IExchange and IQueue used by the underlying IConsumer; these can be further manipulated using the advanced API IAdvancedBus if required.

You can cancel a subscriber at any time by calling Dispose on the ISubscriptionResult instance or on its ConsumerCancellation property:

var subscriptionResult = bus.Subscribe<MyMessage>("sub_id", MyHandler);
subscriptionResult.Dispose();

This will stop EasyNetQ consuming from the queue and close the consumer's channel. It is the equivalent to calling subscriptionResult.ConsumerCancellation.Dispose();

Note that disposing of the IBus or IAdvancedBus instance will also cancel all consumers and close the connection to RabbitMQ.

主站蜘蛛池模板: 宁都县| 林口县| 宁安市| 绍兴县| 庆城县| 定安县| 祥云县| 丹棱县| 攀枝花市| 华宁县| 惠东县| 屯门区| 宿松县| 丽江市| 天津市| 扶余县| 枞阳县| 准格尔旗| 苗栗市| 卓尼县| 桦甸市| 祥云县| 华坪县| 太白县| 隆化县| 仙游县| 鹿邑县| 南通市| 于田县| 包头市| 涿鹿县| 仙居县| 天祝| 桃园县| 建宁县| 海口市| 广平县| 隆德县| 徐汇区| 永春县| 灵武市|