1

I have a WebJob getting messages from Service bus which is working fine. If the webjob fails to finish or throws exception the message is sent back in the queue which is fine in itself.

I have set MaxDequeueCount to 10 and it is not a problem if it fails in some cases as it will try to process it again. But the problem is that the message seems to be sent to the bottom of the queue and other messages are handled before we get back to the first failed one.

I would like to handle one message at a time because I might have multiple updates on the same entity coming in a row. If the order changes it would update the entity in wrong order.

Is if it is possible to send the message back infront of the queue on error or continue working on the same message until we reach the MaxDequeueCount?

1 Answers1

0

Ideally, you should not be relying on message order.

Given your requirement, you could potentially go with the FIFO semantics of Azure Service Bus Sessions. When a message is handled within a session and message is aborted, it will be handled once again rather than go to the end of the queue. You need to keep in mind the following:

  1. Can only process one message at a time
  2. Requires session to be used
  3. If message is not completed and not aborted, it will be left hanging in the queue and will be picked up when a session is restarted.
Sean Feldman
  • 23,443
  • 7
  • 55
  • 80