简体   繁体   中英

Azure Service Bus adding message to the queue too quickly

I'm having an issue where I'm triggering an event which is being handled by an Azure Function Service Bus Trigger.

The trigger that runs could run for anywhere up to an hour which is fine but I'm finding that after 5 minutes the message gets re added to the queue, so it's getting handled repeatedly.

I can hack around this by ensuring that this specific topic will only read the message once by changing the MaxDeliveryCount but ideally I'd like the lock to have a longer expiry time than the function (max 1 hour).

According to the Microsoft Documentation it should already do this but I'm still getting the issue when it's re queueing the message.

The Functions runtime receives a message in PeekLock mode. It calls Complete on the message if the function finishes successfully, or calls Abandon if the function fails. If the function runs longer than the PeekLock timeout, the lock is automatically renewed as long as the function is running.

Any ideas?

Azure Service Bus can only lock a message for a maximum of 5 minutes at a time. But it can also renew the lock, which, technically, can allow messages to be locked for as long as needed as long as there are no failures to issue the locking requests. In addition to that, there's a limit on the execution time functions can have. For example, on the Consumption plan, a function won't run longer than the maximum 10 minutes. For any processing longer than that, one should either look into alternatives, that include but are not limited to the following:

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