Ejemplo n.º 1
0
        public async Task DeadletterMessage(string connectionString, string topicPath, string subscriptionPath,
                                            Message message)
        {
            var path = EntityNameHelper.FormatSubscriptionPath(topicPath, subscriptionPath);

            var receiver = new MessageReceiver(connectionString, path, ReceiveMode.PeekLock);

            while (true)
            {
                var messages = await receiver.ReceiveAsync(_maxMessageCount);

                if (messages == null || messages.Count == 0)
                {
                    break;
                }

                var foundMessage = messages.FirstOrDefault(m => m.MessageId.Equals(message.MessageId));
                if (foundMessage != null)
                {
                    await receiver.DeadLetterAsync(foundMessage.SystemProperties.LockToken);

                    break;
                }
            }

            await receiver.CloseAsync();
        }
Ejemplo n.º 2
0
        public async Task DeleteMessage(string connectionString, string queue,
                                        Message message, bool isDlq)
        {
            var path = isDlq ? EntityNameHelper.FormatDeadLetterPath(queue) : queue;

            var receiver = new MessageReceiver(connectionString, path, ReceiveMode.PeekLock);

            while (true)
            {
                var messages = await receiver.ReceiveAsync(_maxMessageCount);

                if (messages == null || messages.Count == 0)
                {
                    break;
                }

                var foundMessage = messages.FirstOrDefault(m => m.MessageId.Equals(message.MessageId));
                if (foundMessage != null)
                {
                    await receiver.CompleteAsync(foundMessage.SystemProperties.LockToken);

                    break;
                }
            }

            await receiver.CloseAsync();
        }
Ejemplo n.º 3
0
        public async Task ResubmitDlqMessage(string connectionString, string queue, Message message)
        {
            var azureMessage = await PeekDlqMessageBySequenceNumber(connectionString, queue, message.SequenceNumber);

            var clonedMessage = azureMessage.CloneMessage();

            await SendMessage(connectionString, queue, clonedMessage);

            await DeleteMessage(connectionString, queue, message, true);
        }
Ejemplo n.º 4
0
        public async Task ResubmitDlqMessage(string connectionString, string topicPath, string subscriptionPath,
                                             Message message)
        {
            var azureMessage = await PeekDlqMessageBySequenceNumber(connectionString, topicPath, subscriptionPath,
                                                                    message.SequenceNumber);

            var clonedMessage = azureMessage.CloneMessage();

            await SendMessage(connectionString, topicPath, clonedMessage);

            await DeleteMessage(connectionString, topicPath, subscriptionPath, message, true);
        }
Ejemplo n.º 5
0
        public async Task DeadletterMessage(string connectionString, string queue, Message message)
        {
            var receiver = new MessageReceiver(connectionString, queue, ReceiveMode.PeekLock);

            while (true)
            {
                var messages = await receiver.ReceiveAsync(_maxMessageCount);

                if (messages == null || messages.Count == 0)
                {
                    break;
                }

                var foundMessage = messages.FirstOrDefault(m => m.MessageId.Equals(message.MessageId));
                if (foundMessage != null)
                {
                    await receiver.DeadLetterAsync(foundMessage.SystemProperties.LockToken);

                    break;
                }
            }

            await receiver.CloseAsync();
        }