public async Task Peek_IncrementsSequenceNmber(int messageCt) { await using (var scope = await ServiceBusScope.CreateWithQueue(enablePartitioning: false, enableSession: true)) { await using var sender = new ServiceBusSenderClient(TestEnvironment.ServiceBusConnectionString, scope.QueueName); var sessionId = Guid.NewGuid().ToString(); // send the messages IEnumerable <ServiceBusMessage> sentMessages = GetMessages(messageCt, sessionId); await sender.SendRangeAsync(sentMessages); await using var receiver = new SessionReceiverClient(sessionId, TestEnvironment.ServiceBusConnectionString, scope.QueueName); long seq = 0; for (int i = 0; i < messageCt; i++) { ServiceBusMessage msg = await receiver.PeekAsync(); Assert.IsTrue(msg.SystemProperties.SequenceNumber > seq); if (seq > 0) { Assert.IsTrue(msg.SystemProperties.SequenceNumber == seq + 1); } seq = msg.SystemProperties.SequenceNumber; } } }
public async Task Peek_IncrementsSequenceNmber(int messageCt) { var sender = new ServiceBusSenderClient(ConnString, SessionQueueName); var sessionId = Guid.NewGuid().ToString(); // send the messages IEnumerable <ServiceBusMessage> sentMessages = GetMessages(messageCt, sessionId); await sender.SendRangeAsync(sentMessages); var receiver = new SessionReceiverClient(sessionId, ConnString, SessionQueueName); long seq = 0; for (int i = 0; i < messageCt; i++) { ServiceBusMessage msg = await receiver.PeekAsync(); Assert.IsTrue(msg.SystemProperties.SequenceNumber > seq); if (seq > 0) { Assert.IsTrue(msg.SystemProperties.SequenceNumber == seq + 1); } seq = msg.SystemProperties.SequenceNumber; } }