- Hands-On Microservices with C#
- Matt R. Cole
- 149字
- 2021-07-23 17:25:20
Message subscriptions
Now that we have shown you what a deployment message looks like, let's discuss what happens when you subscribe to a message.
An EasyNetQ subscriber subscribes to a message type (the .NET type of the message class). Once the subscription to a type has been set up by calling the Subscribe method, a persistent queue will be created on the RabbitMQ broker and any messages of that type will be placed on the queue. RabbitMQ will send any messages from the queue to the subscriber whenever it is connected.
To subscribe to a message, we need to give EasyNetQ an action to perform whenever a message arrives. We do this by passing the Subscribe method a delegate such as this:
bus.Subscribe<MyMessage>("my_subscription_id", msg => Console.WriteLine(msg.Text));
Now, every time an instance of MyMessage is published, EasyNetQ will call our delegate and print the message's Text property to the console.
- 大數據導論:思維、技術與應用
- Dreamweaver CS3+Flash CS3+Fireworks CS3創意網站構建實例詳解
- Python Artificial Intelligence Projects for Beginners
- 走入IBM小型機世界
- TIBCO Spotfire:A Comprehensive Primer(Second Edition)
- 計算機應用復習與練習
- 模型制作
- SharePoint 2010開發最佳實踐
- 中國戰略性新興產業研究與發展:智能制造
- 智能生產線的重構方法
- Building a BeagleBone Black Super Cluster
- Spatial Analytics with ArcGIS
- 和機器人一起進化
- 貫通Hibernate開發
- 計算智能算法及其生產調度應用