Azure服务总线: Receive all the message from one session id of a queue

标签 azure azureservicebus azure-servicebus-queues

我有 2 个问题未能找到任何解决方案。

  1. Azure 服务总线队列中是否有任何内置方式,我只能从 session 处理程序中的一个 session (针对该 sessionId)接收消息。

  2. 还有什么方法可以让我仅从该 session 的死信队列接收消息。

我可以在代码中以编程方式执行此操作,但我不想在代码中编写 if else 逻辑。

最佳答案

Is there any built in way in azure service bus queue, where I can receive messages only from one session (for that sessionId) in my session handler.

正如 Sean Feldman 提到的,Queue​Client.​Accept​Message​Session​Async(sessionID) 允许在普通队列中实现这一点。

如果想使用Queue​Client.​Accept​Message​Session​Async(sessionID)来接收队列消息,我们需要创建RequiresSession 真实

var description = new QueueDescription(QueueName) 
{ 
    RequiresSession = true 
}; 

namespaceManager.CreateQueue(description);

Also is there any way I can receive messages only from the deadlettered queue for that session alone.

根据我的测试,我们无法使用以下代码从死信队列获取死信队列消息

   var dlqName= QueueClient.FormatDeadLetterPath(queueName);
   var dlqClient = QueueClient.CreateFromConnectionString(connectionstring, dfQueue);
   var gid = Guid.NewGuid().ToString();
   var messageSession = client.AcceptMessageSession(gid);
   var receiveMessage = messageSession.Receive();

Cannot create a MessageSession for a sub-queue. TrackingId:06a39820-7bf6-412d-ab31-80ef5c174a12_G20_B31, SystemTracker:tomsbservice:Queue: queuename |$DeadLetterQueue

我的解决方法是我们可以获取死信队列消息并提交到队列或另一个普通队列。

关于Azure服务总线: Receive all the message from one session id of a queue,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44363543/

相关文章:

azure - 将 Azure SAP 或 SharePoint 连接器连接到 OnPremise 失败

azure - 监听队列(事件驱动,无轮询)服务总线/存储队列

c# - Azure 服务总线队列 - 如何防止 IHostedService 立即处理队列消息

azure - 监控azure服务总线队列长度

database - LINQ 检索语句未返回最新更新的结果

azure - 如何从 Azure 数据工厂中的 Key Vault 获取/设置参数化连接字符串?

azure - 如何获取 Azure 主题订阅的消息计数?

c# - 获取 Azure 服务总线中的消息统计信息

c# - 在 ASP.NET Core 中获取浏览器语言?

c# - 在 ASP.net MVC 中划分大任务的最佳实践