简体   繁体   中英

Azure Service Bus: Delete Session Messages

I am using Azure Service Bus with .NET core

In our application, we are sending Session Messages to Service Bus. Whenever we receive a cancellation request with the session-Id, we need to remove/delete/complete messages with that specific sessionId without any further processing

I tried to access the MessageSession from another receiver to cancel messages from the queue在此处输入图像描述

But I got error - The requested session 'session-name' cannot be accepted. It may be locked by another receiver.

Is there any other possible way to delete messages from service bus queue with a specific sessionId (session may be locked in few cases)

The only workaround, I'm able to get is

Update in database stating sessionId is cancelled & checking this for each message. But this is not efficient for a large number of messages, as we need to extra DB hit for each message.

Is there any other possible way to delete messages from service bus queue with a specific sessionId?

It is possible to delete the message with SessionId using a search feature in Serverless360 where you can specify the query as SessionId = "1" and retrieve the message and delete it. But, it is obvious that you cannot retrieve session messages when it is locked and hence your second test case is not possible anyhow unless you could manage to use some action like renew lock in your orchestration with some delay in processing the messages.

Below is the screenshot of sample orchestration where each time the lock gets renewed and hence you can retrieve the message once you have the Session-Id在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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