How to receive the message from service bus using Rest Api

Kumar, Vikas 20 Reputation points
2023-11-22T09:10:10.08+00:00

Hi,

Can you please let me know how we can receive the message from service bus using Rest api. Please note I have used Peek-Lock Message (Non-Destructive Read) https://video2.skills-academy.com/en-us/rest/api/servicebus/peek-lock-message-non-destructive-read?view=rest-servicebus-controlplane-2022-10-01-preview and it worked for me, but i am able to see only the first message in the response. Please confirm how i can receive message using some filters example from messageBody.

Thanks!

Azure Service Bus
Azure Service Bus
An Azure service that provides cloud messaging as a service and hybrid integration.
633 questions
{count} votes

Accepted answer
  1. JananiRamesh-MSFT 27,831 Reputation points
    2023-11-22T13:09:33.4366667+00:00

    @Kumar, Vikas Thanks for reaching out. When using the Peek-Lock method to retrieve messages from an Azure Service Bus queue, the messages are processed in the order they were added to the queue, following a First-In-First-Out (FIFO) model. The Peek-Lock method allows you to retrieve the next available message from the queue, but you must complete or abandon the message at the front of the queue before you can access the next one. This ensures that messages are processed in the correct order and that no messages are lost or duplicated.

    Filters can’t be used in this scenario because the Peek-Lock method only interacts with the first message in the queue. It doesn’t have the ability to scan through the queue and select messages based on certain criteria or properties. That’s why you’re only able to see the first message in the response.

    please refer: https://video2.skills-academy.com/en-us/rest/api/servicebus/peek-lock-message-non-destructive-read

    let me know incase of further queries, I would be happy to assist you.

    Please 'Accept as answer' and ‘Upvote’ if it helped so that it can help others in the community looking for help on similar topics.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.