繁体   English   中英

发送到 Azure 服务总线主题的消息如何知道对 go 的哪个订阅?

[英]How do messages sent to an Azure Service Bus Topic know which subscription to go to?

我想实施 Azure 服务总线主题/订阅。 像这样的东西

在此处输入图像描述

我正在查看Azure Docs中的 Python 实现。 我不明白的是,发送消息时,它如何知道 go 的哪个订阅?

def send_single_message(sender):
    # create a Service Bus message
    message = ServiceBusMessage("Single Message")
    # send the message to the topic
    sender.send_messages(message)
    print("Sent a single message")

# create a Service Bus client using the connection string
servicebus_client = ServiceBusClient.from_connection_string(conn_str=CONNECTION_STR, logging_enable=True)
with servicebus_client:
    # get a Topic Sender object to send messages to the topic
    sender = servicebus_client.get_topic_sender(topic_name=TOPIC_NAME)
    with sender:
        # send one message        
        send_single_message(sender)

print("Done sending messages")
print("-----------------------")

我不明白的是,发送消息时,它如何知道 go 的哪个订阅?

这是通过topic filters完成的。 发送到主题的每条消息都“有点广播”(因为缺少更好的术语)到每个订阅,订阅仅在该消息匹配为该订阅指定的过滤规则之一时才接受该消息。

您可以在此处了解更多信息: https://learn.microsoft.com/en-us/azure/service-bus-messaging/topic-filters

暂无
暂无

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

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