【问题标题】:How to receive Message from topic with Partition Enabled如何在启用分区的情况下接收来自主题的消息
【发布时间】:2018-10-17 12:18:32
【问题描述】:

我已经为主题启用了分区,并且在发送消息时我也添加了 PartitionKey 信息。

但是当我尝试从该主题接收消息时,我无法过滤仅属于特定 PartitionKey 的消息。

我已尝试使用以下代码。它只是返回所有消息而不进行任何过滤。

IEnumerable<BrokeredMessage> messages = mr.PeekBatch(100);

如有任何想法,我将不胜感激。

【问题讨论】:

    标签: c# azure azureservicebus


    【解决方案1】:

    要将消息发送和接收到特定分区,您应该使用服务总线中的会话。

    为主题启用RequiresSession 属性并使用PartitionKeySessionId 发送消息,以便您可以通过在查看消息之前添加AcceptMessageSession([PartitionKey]) 来接收来自特定分区或会话的消息。

    更多详情请参考here

    【讨论】:

    • 您能否建议我如何将“RequiresSession”属性添加到主题,因为在创建主题时我没有看到类似“RequiresSession”属性的任何内容。 @Arunprabhu
    • 您不能在 Azure 门户中设置 RequiresSession 属性。尝试使用 Service Bus Explorer 或 Serverless360 等外部工具在创建主题时设置扩展属性。
    猜你喜欢
    • 2018-10-19
    • 1970-01-01
    • 1970-01-01
    • 2021-08-27
    • 1970-01-01
    • 2019-04-21
    • 2019-06-09
    • 1970-01-01
    • 2023-03-12
    相关资源
    最近更新 更多