Пример #1
0
        /// <summary>
        /// Initializes an Instance of <see cref="AzureServiceBusConsumer"/>
        /// </summary>
        /// <param name="topicName">The name of the Topic.</param>
        /// <param name="subscriptionName">The name of the Subscription on the Topic.</param>
        /// <param name="messageProducerSync">An instance of the Messaging Producer used for Requeue.</param>
        /// <param name="administrationClientWrapper">An Instance of Administration Client Wrapper.</param>
        /// <param name="serviceBusReceiverProvider">An Instance of <see cref="ServiceBusReceiverProvider"/>.</param>
        /// <param name="batchSize">How many messages to receive at a time.</param>
        /// <param name="receiveMode">The mode in which to Receive.</param>
        /// <param name="makeChannels">The mode in which to make Channels.</param>
        /// <param name="subscriptionConfiguration">The configuration options for the subscriptions.</param>
        public AzureServiceBusConsumer(string topicName, string subscriptionName,
                                       IAmAMessageProducerSync messageProducerSync, IAdministrationClientWrapper administrationClientWrapper,
                                       IServiceBusReceiverProvider serviceBusReceiverProvider, int batchSize = 10,
                                       ServiceBusReceiveMode receiveMode = ServiceBusReceiveMode.ReceiveAndDelete,
                                       OnMissingChannel makeChannels     = OnMissingChannel.Create,
                                       AzureServiceBusSubscriptionConfiguration subscriptionConfiguration = default)
        {
            _subscriptionName            = subscriptionName;
            _topicName                   = topicName;
            _messageProducerSync         = messageProducerSync;
            _administrationClientWrapper = administrationClientWrapper;
            _serviceBusReceiverProvider  = serviceBusReceiverProvider;
            _batchSize                   = batchSize;
            _makeChannel                 = makeChannels;
            _subscriptionConfiguration   = subscriptionConfiguration ?? new AzureServiceBusSubscriptionConfiguration();
            _receiveMode                 = receiveMode;

            GetMessageReceiverProvider();
        }
Пример #2
0
        /// <summary>
        /// Creates a consumer for the specified queue.
        /// </summary>
        /// <param name="subscription">The queue to connect to</param>
        /// <returns>IAmAMessageConsumer</returns>
        public IAmAMessageConsumer Create(Subscription subscription)
        {
            var nameSpaceManagerWrapper = new AdministrationClientWrapper(_clientProvider);

            AzureServiceBusSubscriptionConfiguration config = new AzureServiceBusSubscriptionConfiguration();

            if (subscription is AzureServiceBusSubscription sub)
            {
                config = sub.Configuration;
            }

            return(new AzureServiceBusConsumer(subscription.RoutingKey, subscription.ChannelName,
                                               new AzureServiceBusMessageProducer(nameSpaceManagerWrapper,
                                                                                  new ServiceBusSenderProvider(_clientProvider), subscription.MakeChannels), nameSpaceManagerWrapper,
                                               new ServiceBusReceiverProvider(_clientProvider),
                                               makeChannels: subscription.MakeChannels,
                                               receiveMode: _ackOnRead ? ServiceBusReceiveMode.ReceiveAndDelete : ServiceBusReceiveMode.PeekLock,
                                               batchSize: subscription.BufferSize,
                                               subscriptionConfiguration: config));
        }
 /// <summary>
 /// Initializes an Instance of <see cref="AzureServiceBusSubscription"/>
 /// </summary>
 /// <param name="dataType">The type for this Subscription.</param>
 /// <param name="name">The name. Defaults to the data type's full name.</param>
 /// <param name="channelName">The channel name. Defaults to the data type's full name.</param>
 /// <param name="routingKey">The routing key. Defaults to the data type's full name.</param>
 /// <param name="bufferSize">The number of messages to buffer on the channel</param>
 /// <param name="noOfPerformers">The no of performers.</param>
 /// <param name="timeoutInMilliseconds">The timeout in milliseconds.</param>
 /// <param name="requeueCount">The number of times you want to requeue a message before dropping it.</param>
 /// <param name="requeueDelayInMs">The number of milliseconds to delay the delivery of a requeue message for.</param>
 /// <param name="unacceptableMessageLimit">The number of unacceptable messages to handle, before stopping reading from the channel.</param>
 /// <param name="isAsync"></param>
 /// <param name="channelFactory">The channel factory to create channels for Consumer.</param>
 /// <param name="makeChannels">Should we make channels if they don't exist, defaults to creating</param>
 /// <param name="subscriptionConfiguration">The configuration options for the subscriptions.</param>
 /// <param name="emptyChannelDelay">How long to pause when a channel is empty in milliseconds</param>
 /// <param name="channelFailureDelay">How long to pause when there is a channel failure in milliseconds</param>
 public AzureServiceBusSubscription(
     Type dataType,
     SubscriptionName name        = null,
     ChannelName channelName      = null,
     RoutingKey routingKey        = null,
     int bufferSize               = 1,
     int noOfPerformers           = 1,
     int timeoutInMilliseconds    = 400,
     int requeueCount             = -1,
     int requeueDelayInMs         = 0,
     int unacceptableMessageLimit = 0,
     bool isAsync = false,
     IAmAChannelFactory channelFactory = null,
     OnMissingChannel makeChannels     = OnMissingChannel.Create,
     AzureServiceBusSubscriptionConfiguration subscriptionConfiguration = null,
     int emptyChannelDelay   = 500,
     int channelFailureDelay = 1000)
     : base(dataType, name, channelName, routingKey, bufferSize, noOfPerformers, timeoutInMilliseconds, requeueCount, requeueDelayInMs, unacceptableMessageLimit, isAsync, channelFactory,
            makeChannels, emptyChannelDelay, channelFailureDelay)
 {
     Configuration = subscriptionConfiguration ?? new AzureServiceBusSubscriptionConfiguration();
 }