简体   繁体   English

一对多(唯一)的Azure Service Bus队列与主题

[英]Azure Service Bus Queues vs Topics for one to many(unique)

I have an online service hosted on Azure, that asynchronously sends data to on-premise clients. 我在Azure上托管了一个在线服务,该服务异步将数据发送到内部客户端。 Each client is identified by an unique code. 每个客户端由唯一的代码标识。

Actually there is a single topic, with a subscription for each client which has a filter on the unique code, that is sent as a parameter in the message. 实际上,只有一个主题,每个客户端的订阅都有一个针对唯一代码的过滤器,该订阅作为消息中的参数发送。 No message will ever be broadcasted to all the clients. 没有消息将广播到所有客户端。

I feel that using topic this way is wrong. 我觉得以这种方式使用主题是错误的。 The alternative that comes to my mind is to use a dedicated queue for each client, that is created on first contact 我想到的另一种选择是为每个客户使用专用队列,该队列是在首次联系时创建的

Could this be a better approach? 这是更好的方法吗?

Thanks 谢谢

Creating a separate Queue for each client is not advisable. 不建议为每个客户端创建单独的队列。 This is the problem solved by Topics. 这是主题解决的问题。

If you have separate Queue for each client, then you need to send messages to multiple Queues from Server. 如果每个客户端都有单独的队列,则需要将消息从服​​务器发送到多个队列。 This will become tedious when the number of clients increases. 当客户数量增加时,这将变得乏味。

Having a single Topic and multiple Subscriptions is easy to manage as the message will be sent only to a single Topic from Server. 具有单个主题和多个订阅很容易管理,因为消息将仅从服务器发送到单个主题。

In my opinion using Topics and Subscriptions is the right way to go. 我认为使用Topics and Subscriptions是正确的方法。 Here's the reason why: 原因如下:

Currently the routing logic (which message needs to go to which subscription) is handled by Azure Service Bus based on the rules you have configured. 当前,Azure服务总线根据您配置的规则处理路由逻辑(哪些消息需要转到哪个订阅)。 If you go with queues, the routing logic will need to come to your hosted service. 如果您使用队列,则路由逻辑将需要进入托管服务。 You'll need to ensure that the queue exists before sending each message. 在发送每条消息之前,您需要确保队列存在。 I think it will increase the complexity at your service level somehow. 我认为这将以某种方式增加您服务级别的复杂性。

Furthermore, topics and subscriptions would enable you to do build an audit trail kind of functionality (not sure if you're looking for this kind of functionality). 此外,主题和订阅将使您能够构建审计跟踪类型的功能(不确定是否要寻找这种功能)。 You can create a separate subscription that has a rule to deliver all messages ( True SQL Rule ) to that subscription along with client specific subscription. 您可以创建一个单独的订阅,该订阅的规则是将所有消息(特定的True SQL Rule )与客户端特定的订阅一起传递到该订阅。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM