예제 #1
0
        public NimbusTopicMessageSender(IQueueManager queueManager, string topicPath)
        {
            _queueManager = queueManager;
            _topicPath = topicPath;

            _topicClient = new Lazy<TopicClient>(() => _queueManager.CreateTopicSender(_topicPath));
        }
예제 #2
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.");
        }
예제 #3
0
        private TopicClient GetTopicClient()
        {
            if (_topicClient != null)
            {
                return(_topicClient);
            }

            _topicClient = _queueManager.CreateTopicSender(_topicPath).Result;
            return(_topicClient);
        }