Working Scenario:
- Post Msg1 to topic
- Post Msg2 to topic
- Read Msg1, Msg2
Not Working:
- Post Msg1 to topic
- Read Msg1 from topic through subscriber, but I'm not marking as complete.(Still on Queue)
- Post Msg2 to topic
Read Msgs.. Actual: I read only Msg2 Expectation: Want to read Msg1, Msg2.
if (namespaceManager.TopicExists(topic)) { var lstOfValues = new List<SITConfirmation>(); SubscriptionClient Client = SubscriptionClient.CreateFromConnectionString(ConfigurationManager.ConectionString(), topic, subscriber); IEnumerable<BrokeredMessage> messages = await Client.ReceiveBatchAsync(10, TimeSpan.FromMilliseconds(500)); }
With
ReceiveBatchAsync(messageCount)
you're not promised to get the exact number of messages requested. Gateway could have all the messages or not. It will return whatever it has (gateway might have less/more/same number of messages that are actually stored on the broker entity).From the documentation: