Azure / azure-service-bus-dotnet

☁️ .NET Standard client library for Azure Service Bus
https://azure.microsoft.com/services/service-bus
Other
235 stars 120 forks source link

Need SequenceNumber of enqueued service bus queue message #658

Closed TaruchuAtWork closed 5 years ago

TaruchuAtWork commented 5 years ago

Feature Request

Hey Microsoft,

I'm building a messaging pipeline that needs the ability to put both direct and scheduled messages into multiple queues. I want to provide developers using my service the ability to put messages into a Queue and the ability to query for the status of a particular message.

Currently when I queue a Message using Microsoft.Azure.ServiceBus.QueueClient.SendAsync(Message) it doesn't look like the SystemProperties on the enqueued Message object get updated with the SequenceNumber, and the SendAsync method doesn't return a SequenceNumber either. To see if my message is on the queue I use the batch peek method called Microsoft.Azure.ServiceBus.Core. MessageReceiver.PeekAsync(Int32) and perform a linq query on the result in order to filter out one message based on a Microsoft.Azure.ServiceBus.Message.UserProperties key value pair that I assign before sending.

The overhead using this method should be apparent, as I may need to iterate the entire Queue depending on where the message is. I would ideally like to use the Peek method that accepts a sequence number argument and returns a single message that already exists called Microsoft.Azure. ServiceBus.Core.MessageReceiver.PeekBySequence. Is there a reason SendAsync doesn't update the SystemProperties of the Message object or return the sequence number directly?

Thanks :-)

SeanFeldman commented 5 years ago

@TaruchuAtWork have you looked at queueClient.CancelScheduledMessageAsync()? It does what sounds like what you need, schedules a message and returns the sequence number. More info here.

TaruchuAtWork commented 5 years ago

Thanks @sean Correct, but I also need access to the sequence number of a message that I send without scheduling. That way I can utilize Microsoft.Azure. ServiceBus.Core.MessageReceiver.PeekBySequence to peek. What are your thoughts on why SendAsync doesn't update the SystemProperties.SequenceNumber of the Message object or return the sequence number directly? Could this feature be added please ?

SeanFeldman commented 5 years ago

I think you're asking in the wrong repo. SendAsync implements what the broker is capable. If the broker expects to receive a message and doesn't send back sequence number, this client (repo) can't change it. That would be a feature request for the broker to raise here.

TaruchuAtWork commented 5 years ago

Thanks @SeanFeldman , I just wanted to confirm that the client wasn't responsible for hydrating the sequence number property. I'll close this question and open a feature request in the server (repo) at the link you provided. Awesome :-)