- 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.
- 腦動(dòng)力:Linux指令速查效率手冊(cè)
- Mastering Spark for Data Science
- 蕩胸生層云:C語(yǔ)言開(kāi)發(fā)修行實(shí)錄
- Windows環(huán)境下32位匯編語(yǔ)言程序設(shè)計(jì)
- 西門(mén)子變頻器技術(shù)入門(mén)及實(shí)踐
- Red Hat Linux 9實(shí)務(wù)自學(xué)手冊(cè)
- 分析力!專業(yè)Excel的制作與分析實(shí)用法則
- INSTANT Puppet 3 Starter
- Mastering Ansible(Second Edition)
- MPC5554/5553微處理器揭秘
- Learn Microsoft Azure
- 筆記本電腦使用與維護(hù)
- Raspberry Pi Projects for Kids
- JSP網(wǎng)絡(luò)開(kāi)發(fā)入門(mén)與實(shí)踐
- 工業(yè)機(jī)器人與自控系統(tǒng)的集成應(yīng)用