How to read multiple messages from a service bus topic subscription under peek lock with http request not via service bus connector and using managed identity authentication?
Using REST API, it is not possible to get multiple messages in a single request. The REST API operation is Peek-Lock Message which only returns a single message.
If you have to fetch multiple messages, either call this operation multiple times on a topic subscription or make use of AMQP which supports fetching multiple messages.
Related
I am a beginner in Azure and using PHP and Azure Manager or Service REST API passing a message to queue or subscriber.
I am able to send and receive messages using a service API (servicebus.windows.net).
is that way to send and receive messages using Azure Manager API(Management.azure.com)?
No there is no way, with the management API you can do certain operations such as deleting the namespace, authorization rules, entities,etc.
Sending and Receiving messages are data operations that can only be done via the Service API.
I am using peek method to view the messages in the queue; the messages returned contain both the ones sitting in the queue and the ones being processed;
I also looked at the management api which provides active message count again it includes both sitting and being processed messages.
is there a way to get both the counts separately?
You can use Azure Monitor API: https://learn.microsoft.com/en-us/azure/service-bus-messaging/service-bus-metrics-azure-monitor
Management API: https://learn.microsoft.com/en-us/rest/api/monitor/metrics/list
Example:
/subscriptions/{subscriptionID}/resourceGroups/{resourcegroup}/providers/Microsoft.ServiceBus/namespaces/{namespacename}/providers/microsoft.Insights/metrics?timespan=2020-08-06T05:18:00.000Z/2020-08-06T06:18:00.000Z&interval=FULL&metricnames=ActiveMessages&aggregation=average&metricNamespace=microsoft.servicebus%2Fnamespaces&top=10&$filter=EntityName eq '{your entityname}'&rollupby=EntityName&validatedimensions=false&api-version=2019-07-01
I am new to Azure Service Bus and I found that I need to continuously poll for Queue messages in order to receive them. However, I want the Queue to push the message to some sort of listener on the client-side of things without it having to poll for messages.
I have read that polling is optional in Azure Service Bus but I couldn't find how to receive messages without it.
Please help if you can. Thank you
I have read that polling is optional in Azure Service Bus but I couldn't find how to receive messages without it.
Polling is optional if you start receiving on demand. Otherwise, it's not optional and long-polling will take place.
I want the Queue to push the message to some sort of listener on the client-side of things without it having to poll for messages.
There's a way to achieve exactly that using Event Grid integration with Azure Service Bus. Service Bus will emit an event to notify about messages awaiting processing and no active listeners. That way your application/system reacts and doesn't have to poll.
Note that the key scenario for this feature is low volume of messages that do not need to have a receiver that polls for messages continuously.
It should be possible. Take a look on the following to get an idea on how it could be done:
Get started with Service Bus topics
Get started with Service Bus queues
Hope it helps!
I have following requirement
Message published to the Topic/Queue
Multiple consumers subscribed to the Topic/Queue. So our requirement is to only one consumer should listen to the message. That means no other consumer can get the same message.
I feel queue would be the best fit. But I have advise from our architect to check whether we can achieve it from Topics?.
So any body please let me know whether we can achieve it through Topics and also pros and constrains?
Thanks.
Azure Service Bus Queue is a single message queue. You send it a message and the message receiver will get the message and be able to process it accordingly. Each message will only be handled once.
Azure Service Bus Topic is a more robust message queue than Azure Service Bus Queue. With Topics there can be multiple Subscriptions configured to catch messages based on a Filter. If multiple Subscriptions have a Filter that matches an incoming message, then each of those Subscriptions will get a copy of the messages. With Topics it's up to you to configure the Subscription Filters according to your projects needs.
If you know a message only needs to be handled once in your system and the message queue is being used by a single message receiver application (single or multiple hosted instances) then Azure Service Bus Queue is likely the tool for the job.
I'm trying to integrate with the Azure Service Bus to perform brokered messaging. I've used the managed .NET API successfully before, but this time I need to use the HTTP API.
When processing a message, if I determine that a message is poisonous (i.e. it can never be processed successfully), I want to move the message to the dead-letter queue.
In the managed API, I'd call BrokeredMessage.DeadLetterAsync() which lets me specify the reasons for dead-lettering the message and moves it to the dead-letter queue as an atomic operation.
Having been reading through the HTTP API documentation, I've found and invoked operations to perform the other actions, such as peek-lock, delete a locked message or abandon a lock, but I can't find an explicit operation to dead-letter a message.
Does this operation exist in the HTTP API?
DeadLetter operation today is not supported thru the http/rest API. We will add that support in an upcoming release. When the max delivery count for any message is reached and it is still not completed then it will be automatically deadlettered if that is enabled for the queue/subscription. The connectivity mode mentioned above is for the .NET API where the SBMP service bus protocol is tunneled over a http/port80 connection so it is not using REST APIs for that.
Even though I did not find any documentation for it, you can access dead letter messages via:
https://{servicebusnamespace}/{topic}/subscriptions/{subscriptionname}/$deadletterqueue/messages/head
I took a look at the REST Api Reference too and I could not find a way. There's a comparative table that shows features that are available through REST Api and features available through .NET SDK.
http://msdn.microsoft.com/en-us/library/windowsazure/hh780771.aspx
It sounds strange for me because I thought that .NET SDK calls a REST API Resource.
I believe that you must apply Peek-Lock on a message and after the processing, delete it.
Peek-lock message:
http://msdn.microsoft.com/en-us/library/windowsazure/hh780735.aspx
Delete:
http://msdn.microsoft.com/en-us/library/windowsazure/hh780768.aspx