public static async Task QueueWithSessionsBatch(
                [ServiceBusTrigger(FirstQueueNameKey, IsSessionsEnabled = true)]
                ServiceBusReceivedMessage[] array,
                string[] sessionIdArray,
                ServiceBusSessionMessageActions sessionActions,
                CancellationToken cancellationToken,
                ILogger logger)
            {
                Assert.True(array.Length > 0);
                logger.LogInformation(
                    $"DrainModeTestJobBatch.QueueWithSessionsBatch: received {array.Length} messages with session id {array[0].SessionId}");
                Assert.AreEqual(_drainModeSessionId, array[0].SessionId);
                _drainValidationPreDelay.Set();
                await DrainModeHelper.WaitForCancellation(cancellationToken);

                Assert.True(cancellationToken.IsCancellationRequested);
                int index = 0;

                foreach (ServiceBusReceivedMessage msg in array)
                {
                    Assert.AreEqual(msg.SessionId, sessionIdArray[index++]);
                    // validate that manual lock renewal works
                    var initialLockedUntil = sessionActions.SessionLockedUntil;
                    await sessionActions.RenewSessionLockAsync();

                    Assert.Greater(sessionActions.SessionLockedUntil, initialLockedUntil);

                    await sessionActions.CompleteMessageAsync(msg);
                }

                _drainValidationPostDelay.Set();
            }
            public static async Task QueueNoSessions(
                [ServiceBusTrigger(FirstQueueNameKey)] ServiceBusReceivedMessage msg,
                ServiceBusMessageActions messageActions,
                CancellationToken cancellationToken,
                ILogger logger)
            {
                logger.LogInformation($"DrainModeValidationFunctions.QueueNoSessions: message data {msg.Body}");
                _drainValidationPreDelay.Set();
                await DrainModeHelper.WaitForCancellation(cancellationToken);

                Assert.True(cancellationToken.IsCancellationRequested);
                await messageActions.CompleteMessageAsync(msg);

                _drainValidationPostDelay.Set();
            }
            public static async Task TopicNoSessions(
                [ServiceBusTrigger(TopicName, TopicSubscriptionName1)] Message msg,
                MessageReceiver messageReceiver,
                CancellationToken cancellationToken,
                ILogger logger)
            {
                logger.LogInformation($"DrainModeValidationFunctions.NoSessions: message data {msg.Body}");
                _drainValidationPreDelay.Set();
                await DrainModeHelper.WaitForCancellation(cancellationToken);

                Assert.True(cancellationToken.IsCancellationRequested);
                await messageReceiver.CompleteAsync(msg.SystemProperties.LockToken);

                _drainValidationPostDelay.Set();
            }
Ejemplo n.º 4
0
            public async static Task TopicWithSessions(
                [ServiceBusTrigger(_topicName, _subscriptionName, IsSessionsEnabled = true)] Message msg,
                IMessageSession messageSession,
                CancellationToken cancellationToken,
                ILogger logger)
            {
                logger.LogInformation($"DrainModeValidationFunctions.TopicWithSessions: message data {msg.Body} with session id {msg.SessionId}");
                Assert.Equal(_drainModeSessionId, msg.SessionId);
                _drainValidationPreDelay.Set();
                await DrainModeHelper.WaitForCancellation(cancellationToken);

                Assert.True(cancellationToken.IsCancellationRequested);
                await messageSession.CompleteAsync(msg.SystemProperties.LockToken);

                _drainValidationPostDelay.Set();
            }
Ejemplo n.º 5
0
            public static async Task TopicWithSessions(
                [ServiceBusTrigger(TopicNameKey, FirstSubscriptionNameKey, IsSessionsEnabled = true)]
                ServiceBusReceivedMessage msg,
                ServiceBusSessionMessageActions messageSession,
                CancellationToken cancellationToken,
                ILogger logger)
            {
                logger.LogInformation(
                    $"DrainModeValidationFunctions.TopicWithSessions: message data {msg.Body} with session id {msg.SessionId}");
                Assert.AreEqual(_drainModeSessionId, msg.SessionId);
                _drainValidationPreDelay.Set();
                await DrainModeHelper.WaitForCancellation(cancellationToken);

                Assert.True(cancellationToken.IsCancellationRequested);
                await messageSession.CompleteMessageAsync(msg);

                _drainValidationPostDelay.Set();
            }
            public static async Task TopicNoSessionsBatch(
                [ServiceBusTrigger(TopicNameKey, FirstSubscriptionNameKey)] ServiceBusReceivedMessage[] array,
                ServiceBusMessageActions messageActions,
                CancellationToken cancellationToken,
                ILogger logger)
            {
                Assert.True(array.Length > 0);
                logger.LogInformation($"DrainModeTestJobBatch.TopicNoSessionsBatch: received {array.Length} messages");
                _drainValidationPreDelay.Set();
                await DrainModeHelper.WaitForCancellation(cancellationToken);

                Assert.True(cancellationToken.IsCancellationRequested);
                foreach (ServiceBusReceivedMessage msg in array)
                {
                    await messageActions.CompleteMessageAsync(msg);
                }
                _drainValidationPostDelay.Set();
            }
            public static async Task TopicNoSessionsBatch(
                [ServiceBusTrigger(TopicName, TopicSubscriptionName1)] Message[] array,
                MessageReceiver messageReceiver,
                CancellationToken cancellationToken,
                ILogger logger)
            {
                Assert.True(array.Length > 0);
                logger.LogInformation($"DrainModeTestJobBatch.TopicNoSessionsBatch: received {array.Length} messages");
                _drainValidationPreDelay.Set();
                await DrainModeHelper.WaitForCancellation(cancellationToken);

                Assert.True(cancellationToken.IsCancellationRequested);
                foreach (Message msg in array)
                {
                    await messageReceiver.CompleteAsync(msg.SystemProperties.LockToken);
                }
                _drainValidationPostDelay.Set();
            }
Ejemplo n.º 8
0
            public async static Task TopicWithSessionsBatch(
                [ServiceBusTrigger(_topicName, _subscriptionName, IsSessionsEnabled = true)] Message[] array,
                MessageReceiver messageReceiver,
                CancellationToken cancellationToken,
                ILogger logger)
            {
                Assert.True(array.Length > 0);
                logger.LogInformation($"DrainModeTestJobBatch.TopicWithSessionsBatch: received {array.Length} messages with session id {array[0].SessionId}");
                Assert.Equal(_drainModeSessionId, array[0].SessionId);
                _drainValidationPreDelay.Set();
                await DrainModeHelper.WaitForCancellation(cancellationToken);

                Assert.True(cancellationToken.IsCancellationRequested);
                foreach (Message msg in array)
                {
                    await messageReceiver.CompleteAsync(msg.SystemProperties.LockToken);
                }
                _drainValidationPostDelay.Set();
            }
Ejemplo n.º 9
0
            public static async Task QueueWithSessionsBatch(
                [ServiceBusTrigger(FirstQueueNameKey, IsSessionsEnabled = true)]
                ServiceBusReceivedMessage[] array,
                ServiceBusMessageActions messageActions,
                CancellationToken cancellationToken,
                ILogger logger)
            {
                Assert.True(array.Length > 0);
                logger.LogInformation(
                    $"DrainModeTestJobBatch.QueueWithSessionsBatch: received {array.Length} messages with session id {array[0].SessionId}");
                Assert.AreEqual(_drainModeSessionId, array[0].SessionId);
                _drainValidationPreDelay.Set();
                await DrainModeHelper.WaitForCancellation(cancellationToken);

                Assert.True(cancellationToken.IsCancellationRequested);
                foreach (ServiceBusReceivedMessage msg in array)
                {
                    await messageActions.CompleteMessageAsync(msg);
                }

                _drainValidationPostDelay.Set();
            }