How do I long pole Azure Service Bus queue using PHP and the Azure REST API

Andy McCormick 5 Reputation points
2023-09-15T02:23:03.31+00:00

I'm new to Azure Service Bus. We're trying to develop an integration between Service Bus and our PHP app. With the PHP SDK retired, it seems we're to use Azure REST API. Problem with this seems that the SDK would use sockets to create an option connection, now we just have the endpoints. I assume we need long-poll our messaging queue, but I'm not sure the best way to go about that. Any thoughts on how where to start and what this solution might look like?
thanks

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

1 answer

Sort by: Most helpful
  1. JananiRamesh-MSFT 27,831 Reputation points
    2023-09-19T05:23:37.9733333+00:00

    Hi Andy McCormick Thanks for reaching out. You’re correct that the Azure SDK for PHP has entered a retirement phase and is no longer officially supported by Microsoft. https://video2.skills-academy.com/en-us/azure/service-bus-messaging/service-bus-php-how-to-use-queues However, you can still use the Azure Service Bus with PHP through the REST API. https://video2.skills-academy.com/en-us/azure/service-bus-messaging/service-bus-php-how-to-use-queues.

    In PHP, you could implement long-polling by making an HTTP request to your Service Bus endpoint and setting a high timeout value. If no messages are available, the server will hold the connection open until a message arrives or the timeout is reached. If a message is received, you can process it and then immediately make another request, effectively keeping a constant connection open.

    but in terms of efficiency, it is hard to tell, ideally it should be something like -->GET call wait for X amount of time--->receives messages--->call GET again.

    this should make the trick, but the only thing will be the performance, if you are planning high throughput then it might not be the best choice.

    Let me know in case of further queries, I would be glad to assist you.

    Please "Upvote" and "Accept" if the answer is helpful so that it can help others in the community.  


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.