- Hands-On Microservices with C#
- Matt R. Cole
- 101字
- 2021-07-23 17:25:21
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.
推薦閱讀
- 大數據戰爭:人工智能時代不能不說的事
- Introduction to DevOps with Kubernetes
- Mastering Spark for Data Science
- Mastercam 2017數控加工自動編程經典實例(第4版)
- Learning Social Media Analytics with R
- 計算機控制技術
- 條碼技術及應用
- Visual C# 2008開發技術實例詳解
- 微型計算機控制技術
- 大數據技術與應用
- Blender Compositing and Post Processing
- Java Web整合開發全程指南
- 電氣控制與PLC原理及應用(歐姆龍機型)
- AVR單片機工程師是怎樣煉成的
- 步步驚“芯”