- 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.
- Internet接入·網(wǎng)絡(luò)安全
- 機器學(xué)習(xí)實戰(zhàn):基于Sophon平臺的機器學(xué)習(xí)理論與實踐
- Managing Mission:Critical Domains and DNS
- R Machine Learning By Example
- 基于LPC3250的嵌入式Linux系統(tǒng)開發(fā)
- Java開發(fā)技術(shù)全程指南
- 人工智能工程化:應(yīng)用落地與中臺構(gòu)建
- 機器自動化控制器原理與應(yīng)用
- 網(wǎng)絡(luò)安全與防護
- 空間站多臂機器人運動控制研究
- Learning Linux Shell Scripting
- Dreamweaver+Photoshop+Flash+Fireworks網(wǎng)站建設(shè)與網(wǎng)頁設(shè)計完全實用
- RealFlow流體制作經(jīng)典實例解析
- Flink內(nèi)核原理與實現(xiàn)
- 軟件需求最佳實踐