Azure Service Bus会话队列逻辑应用完成消息报错及会话关闭疑问
Let me walk you through what's happening here and how to fix it, based on hands-on experience with Service Bus sessions and Logic Apps:
Why You're Seeing These Errors
Let's break down each error you're encountering:
"The lock on the message has been lost": This is the most common issue. When using peek-lock mode, Service Bus assigns a lock to the message for a set duration (default 30 seconds). If your Logic App takes longer than this duration to process the message, the lock automatically releases. Trying to complete the message after that will fail. Since you're only processing one message per session at a time, this is almost always a processing timeout issue, not competing consumers.
"No session available to complete the message": This happens when the session associated with your message has already been closed or expired. Service Bus automatically closes sessions if they're idle longer than the configured session timeout (default 5 minutes). It can also occur if your Logic App's connection to the session drops unexpectedly mid-processing.
"This messaging entity has already been closed, aborted, or disposed": This ties back to the session being terminated—either by the system due to timeout, or by an unexpected disconnect in your Logic App flow. Once the session is closed, any subsequent operations on its messages will fail with this error.
Should You Close the Session After Completing a Message?
The short answer: It depends on your workflow, but managing sessions intentionally will prevent most of these errors.
- If you expect more messages for the same session to arrive soon, leaving the session open is fine—Service Bus keeps the session locked to your Logic App instance, which avoids the overhead of re-acquiring the session for the next message.
- If there's no timeline for the next message in the session (or it will be hours/days later), you should explicitly close the session using the「Close a Session in a queue」connector. Leaving idle sessions open wastes resources, and if the session hits its idle timeout, it will close automatically anyway—leading to the "no session available" errors if you try to process a message afterward.
Fixes & Best Practices to Resolve the Errors
Adjust Timeout Settings
- Increase the Lock Duration for your queue: Go to your Service Bus queue settings, find the Lock Duration option, and set it to a value longer than your Logic App's average processing time for a single message (e.g., 2 minutes if processing takes 1 minute).
- Tune the Session Timeout: If your session messages arrive with large gaps, extend this timeout (default is 5 minutes) to prevent the system from auto-closing sessions prematurely.
Add Error Handling & Retries
- Configure retry policies for the「Complete message in Queue」action: Set up retries with backoff for lock loss errors—sometimes a quick retry can work if the lock was just released.
- Add a failure branch to your Logic App: When these errors occur, log the details, then either move the message to a dead-letter queue (for later analysis) or attempt to re-receive the message (if the lock was lost due to timeout).
Session Management
- For one-off message processing per session: After completing the message, call the「Close a Session in a queue」action to clean up the session explicitly. This avoids unexpected session timeouts and frees up resources.
内容的提问来源于stack exchange,提问作者H4p7ic

