0
votes

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 enter image description here

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.

1

1 Answers

0
votes

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 enter image description here