Beispiel #1
0
 ///  <summary>
 ///  Creates the input channel.
 ///  With SQS we can ensure that queues exist ahead of creating the consumer, as there is no non-durable queue model
 ///  to create ephemeral queues, nor are there non-mirrored queues (on a single node in the cluster) where nodes
 ///  failing mean we want to create anew as we recreate. So the input factory creates the queue
 ///  </summary>
 /// <param name="connection">The connection parameter so create the channel with</param>
 /// <returns>IAmAnInputChannel.</returns>
 public IAmAChannel CreateChannel(Connection connection)
 {
     EnsureQueue(connection);
     return(new Channel(
                connection.ChannelName.ToValidSQSQueueName(),
                _messageConsumerFactory.Create(connection),
                connection.BufferSize
                ));
 }
        ///  <summary>
        ///  Creates the input channel.
        ///  With SQS we can ensure that queues exist ahead of creating the consumer, as there is no non-durable queue model
        ///  to create ephemeral queues, nor are there non-mirrored queues (on a single node in the cluster) where nodes
        ///  failing mean we want to create anew as we recreate. So the input factory creates the queue
        ///  </summary>
        /// <param name="subscription">An SqsSubscription, the subscription parameter so create the channel with</param>
        /// <returns>IAmAnInputChannel.</returns>
        public IAmAChannel CreateChannel(Subscription subscription)
        {
            var channel = _retryPolicy.Execute(() =>
            {
                SqsSubscription sqsSubscription = subscription as SqsSubscription;
                _subscription = sqsSubscription ?? throw new ConfigurationException("We expect an SqsSubscription or SqsSubscription<T> as a parameter");

                EnsureTopic(_subscription.RoutingKey, _subscription.SnsAttributes, _subscription.FindTopicBy, _subscription.MakeChannels);
                EnsureQueue();

                return(new Channel(
                           subscription.ChannelName.ToValidSQSQueueName(),
                           _messageConsumerFactory.Create(subscription),
                           subscription.BufferSize
                           ));
            });

            return(channel);
        }