Ejemplo n.º 1
0
        public async Task DeliverAfter(NimbusMessage message, DateTimeOffset deliveryTime)
        {
            if (await _queueManager.QueueExists(message.DeliverTo))
            {
                message.DeliverAfter = deliveryTime;
                var messageSender = await _queueManager.CreateMessageSender(message.DeliverTo);

                var brokeredMessage = await _brokeredMessageFactory.BuildBrokeredMessage(message);

                await messageSender.SendAsync(brokeredMessage);

                return;
            }

            if (await _queueManager.TopicExists(message.DeliverTo))
            {
                message.DeliverAfter = deliveryTime;
                var topicSender = await _queueManager.CreateTopicSender(message.DeliverTo);

                var brokeredMessage2 = await _brokeredMessageFactory.BuildBrokeredMessage(message);

                await topicSender.SendAsync(brokeredMessage2);

                return;
            }

            throw new NotSupportedException("Message redelivery was requested but neither a queue path nor a topic path could be found.");
        }
Ejemplo n.º 2
0
        public async Task Send(NimbusMessage message)
        {
            await _retry.DoAsync(async() =>
            {
                var brokeredMessage = await _brokeredMessageFactory.BuildBrokeredMessage(message);

                var messageSender = GetMessageSender();
                try
                {
                    await messageSender.SendAsync(brokeredMessage);
                }
                catch (MessagingEntityNotFoundException exc)
                {
                    _logger.Error(exc, "The referenced queue {QueuePath} no longer exists", _queuePath);
                    await _queueManager.MarkQueueAsNonExistent(_queuePath);
                    DiscardMessageSender();
                    throw;
                }
                catch (Exception)
                {
                    DiscardMessageSender();
                    throw;
                }
            },
                                 "Sending message to queue").ConfigureAwaitFalse();
        }
Ejemplo n.º 3
0
        public async Task Send(NimbusMessage message)
        {
            await _retry.DoAsync(async() =>
            {
                var brokeredMessage = await _brokeredMessageFactory.BuildBrokeredMessage(message);

                var topicClient = GetTopicClient();
                try
                {
                    await topicClient.SendAsync(brokeredMessage);
                }
                catch (MessagingEntityNotFoundException exc)
                {
                    _logger.Error(exc, "The referenced topic path {TopicPath} no longer exists", _topicPath);
                    await _queueManager.MarkTopicAsNonExistent(_topicPath);
                    DiscardTopicClient();
                    throw;
                }
                catch (Exception)
                {
                    DiscardTopicClient();
                    throw;
                }
            },
                                 "Sending message to topic").ConfigureAwaitFalse();
        }
Ejemplo n.º 4
0
        public async Task Post(NimbusMessage message)
        {
            var messageSender = await _queueManager.CreateDeadQueueMessageSender();

            var brokeredMessage = await _brokeredMessageFactory.BuildBrokeredMessage(message);

            await messageSender.SendAsync(brokeredMessage);
        }
Ejemplo n.º 5
0
        public async Task DeliverAfter(NimbusMessage message, DateTimeOffset deliveryTime)
        {
            message.DeliverAfter = deliveryTime;
            var messageSender = await _queueManager.CreateMessageSender(message.DeliverTo);

            var brokeredMessage = await _brokeredMessageFactory.BuildBrokeredMessage(message);

            await messageSender.SendAsync(brokeredMessage);
        }