Search code examples
azureazure-logic-appsazure-servicebus-queues

Why does Azure Logic "When a message is received in a queue (peek-lock)" "Next Available" wait so long to pick up a queue message?


My setup:

  • I've created an Azure Service Bus Queue with sessions enabled.
    • Lock duration = 1 minute
  • I've created an Azure Logic App with the trigger "When a message is received in a queue (peek-lock)
    • Session id = Next Available
    • Interval = 15, Frequency = Second
    • If the steps in my Azure Logic App succeed, I Complete the message in a queue, otherwise I Dead-letter the message in a queue

My results:

  • The Azure Logic App picks up one queue message at a time and processes it, but waits the entire Lock duration (in my case, 1 minute) before picking up the next message.
  • Note: When I set Session id to be a specific session id, it does not wait, but processes messages immediately

My question:

  • I'd like the Azure Logic App to process more queue messages immediately after completion when the Session id = Next Available. Is this possible and is there a setting I'm missing to tell the Azure Logic App to not wait the entire lock period?

Solution

  • Do your messages have the same SessionId?

    In that case I think your Logic App is holding the session lock, so you need to use the "Close a session in a queue" task.

    If you have multiple messages with same SessionId, it seems to hold the session lock for one minute before it takes the next message with the same SessionId based on my simple test. Closing the session resulted in immediate processing of the next message in same session.

    I have a similar case in production use where I have to wait for a while and pull all messages with the same SessionId together, but it runs nicely concurrent Logic Apps if there are multiple sessions going on, and that was the same in my test setup.