static void RegisterBasicTransport(StandardConfigurer <ITransport> configurer, string inputQueueAddress, string connectionString, AzureServiceBusTransportSettings settings)
        {
            configurer.Register(c =>
            {
                var rebusLoggerFactory = c.Get <IRebusLoggerFactory>();
                var asyncTaskFactory   = c.Get <IAsyncTaskFactory>();
                var transport          = new BasicAzureServiceBusTransport(connectionString, inputQueueAddress, rebusLoggerFactory, asyncTaskFactory);

                if (settings.PrefetchingEnabled)
                {
                    transport.PrefetchMessages(settings.NumberOfMessagesToPrefetch);
                }

                transport.AutomaticallyRenewPeekLock = settings.AutomaticPeekLockRenewalEnabled;

                transport.PartitioningEnabled      = settings.PartitioningEnabled;
                transport.DoNotCreateQueuesEnabled = settings.DoNotCreateQueuesEnabled;
                return(transport);
            });
        }
示例#2
0
        /// <summary>
        /// Configures Rebus to use Azure Service Bus queues to transport messages, connecting to the service bus instance pointed to by the connection string
        /// (or the connection string with the specified name from the current app.config)
        /// </summary>
        public static AzureServiceBusTransportSettings UseAzureServiceBus(this StandardConfigurer <ITransport> configurer, string connectionStringNameOrConnectionString, string inputQueueAddress, AzureServiceBusMode mode = AzureServiceBusMode.Standard)
        {
            var connectionString = GetConnectionString(connectionStringNameOrConnectionString);
            var settingsBuilder  = new AzureServiceBusTransportSettings();

            if (mode == AzureServiceBusMode.Basic)
            {
                configurer.Register(c =>
                {
                    var rebusLoggerFactory = c.Get <IRebusLoggerFactory>();
                    var transport          = new BasicAzureServiceBusTransport(connectionString, inputQueueAddress, rebusLoggerFactory);

                    if (settingsBuilder.PrefetchingEnabled)
                    {
                        transport.PrefetchMessages(settingsBuilder.NumberOfMessagesToPrefetch);
                    }

                    transport.AutomaticallyRenewPeekLock = settingsBuilder.AutomaticPeekLockRenewalEnabled;

                    transport.PartitioningEnabled = settingsBuilder.PartitioningEnabled;

                    return(transport);
                });

                return(settingsBuilder);
            }

            configurer
            .OtherService <AzureServiceBusTransport>()
            .Register(c =>
            {
                var rebusLoggerFactory = c.Get <IRebusLoggerFactory>();
                var transport          = new AzureServiceBusTransport(connectionString, inputQueueAddress, rebusLoggerFactory);

                if (settingsBuilder.PrefetchingEnabled)
                {
                    transport.PrefetchMessages(settingsBuilder.NumberOfMessagesToPrefetch);
                }

                transport.AutomaticallyRenewPeekLock = settingsBuilder.AutomaticPeekLockRenewalEnabled;

                transport.PartitioningEnabled = settingsBuilder.PartitioningEnabled;

                return(transport);
            });

            configurer
            .OtherService <ISubscriptionStorage>()
            .Register(c => c.Get <AzureServiceBusTransport>(), description: AsbSubStorageText);

            configurer.Register(c => c.Get <AzureServiceBusTransport>());

            configurer.OtherService <IPipeline>().Decorate(c =>
            {
                var pipeline = c.Get <IPipeline>();

                return(new PipelineStepRemover(pipeline)
                       .RemoveIncomingStep(s => s.GetType() == typeof(HandleDeferredMessagesStep)));
            });

            configurer.OtherService <ITimeoutManager>().Register(c => new DisabledTimeoutManager(), description: AsbTimeoutManagerText);

            return(settingsBuilder);
        }