Azure Service Bus - subscribers can independently subscribe to a subscription and share the same message?

醉酒当歌 提交于 2019-12-04 02:12:02

When you create a subscription to a topic it has a specific subscription name. Any consumer that then starts requesting messages for that subscription name will compete for messages on that subscription. If you want independent applications to each receive a copy of the message sent to a topic they will each have to create their own subscription to the topic. You can almost view each subscription as a queue unto itself being fed by the topic.

The example I'll give is of a college. The topic is "New Student" and each department within the college wants to receive a copy of a message for a new student. Thus each department would have it's own subscription. There would be "Music", "Billings", "Science", "Math" subscriptions, etc. Each of them subscribing to the New Student topic. In this way each department receives a copy of the new student message, or can even filter on things they care about if they want. If the department gets behind in processing these they can spin up more instances of the processor using the their subscription name, thus increasing their throughput in theory since more consumers are then competing for the messages in their subscription.

So, in your example, each application would need to either create it's own subscription or be assigned an unique subscription to start pulling from when it starts up. Note that if you let the application lifetime decide the lifetime of a subscription (meaning you create a subscription when the app starts and destroy it when the app closes) you need to be aware that if there are no active subscriptions then messages sent to the topic will simply be lost. You can however create a catch all subscription that only receives messages that are not delivered to any other subscription. It really depends on what you are trying to accomplish.

What you are looking for is not Service Bus but Event Hub. Event Hub is working exactly you describe and can also be accessed by means of AMQP.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!