- 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.
推薦閱讀
- 現(xiàn)代測控電子技術
- PowerShell 3.0 Advanced Administration Handbook
- Dreamweaver 8中文版商業(yè)案例精粹
- Visual FoxPro 6.0數(shù)據(jù)庫與程序設計
- 計算機原理
- Dreamweaver CS3網(wǎng)頁設計與網(wǎng)站建設詳解
- Mastering Elastic Stack
- AWS Certified SysOps Administrator:Associate Guide
- PostgreSQL 10 Administration Cookbook
- Visual FoxPro程序設計
- R Data Analysis Projects
- WOW!Photoshop CS6完全自學寶典
- 計算智能算法及其生產(chǎn)調(diào)度應用
- 手把手教你學Photoshop CS3
- 深度學習之模型優(yōu)化:核心算法與案例實踐