Warm tip: This article is reproduced from stackoverflow.com, please click
azure azureservicebus azure-servicebus-topics azure-servicebus-subscriptions

ReceiveAsync from Azure Service Bus topic without a body

发布于 2020-03-27 15:45:23

I'm creating a consumer of an Azure Service Bus topic (subscription) that does nothing but store some statistics. The messages sent to the topic contains a rather large body, that is handled by another consumer on a second subscription on the same topic.

Since the statistics consumer can handle a large number of messages in one go, I was wondering if it is possible to receive a lot of messages but leave out the body to improve performance when communicating with Service Bus and to receive even more messages in one go.

I'm currently doing this:

this.messageReceiver = new MessageReceiver(conn, path);
...
await messageReceiver.ReceiveAsync(10, TimeSpan.FromSeconds(5));

It works pretty sweet but it would be nice to be able to receive 100 or more messages, without having to worry about moving large messages over the network.

Before anyone suggests it, I already know that I can ask for a count, etc. on a topic subscription. I still need the Message object since that contains an entry in the UserProperties dictionary that is used to calculate the stats.

Questioner
ThomasArdal
Viewed
108
Sean Feldman 2020-02-03 13:06

Not possible. You can peek, but that brings the whole payload and headers w/o incrementing the DeliveryCount of the message. You could request it as a broker feature here.