예제 #1
0
        protected override void DoRun()
        {
            using (var transport = new AzureServiceBusTransport(GetConnectionString(ConnectionStringName), InputQueue, LoggerFactory))
            {
                var returnToSourceQueue = new ReturnToSourceQueue(transport)
                {
                    InputQueue = InputQueue,
                    DefaultOutputQueue = DefaultOutputQueue
                };

                returnToSourceQueue.Run();
            }
        }
예제 #2
0
파일: Program.cs 프로젝트: RichieYang/Rebus
        protected override void DoRun()
        {
            var busLifetimeEvents = new BusLifetimeEvents();
            using (var transport = new AzureServiceBusTransport(GetConnectionString(ConnectionStringName), InputQueue, LoggerFactory, new TplAsyncTaskFactory(LoggerFactory), busLifetimeEvents))
            {
                var returnToSourceQueue = new ReturnToSourceQueue(transport)
                {
                    InputQueue = InputQueue,
                    DefaultOutputQueue = DefaultOutputQueue
                };

                returnToSourceQueue.Run();
            }
        }
        /// <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)
        {
            var connectionString = GetConnectionString(connectionStringNameOrConnectionString);
            var settingsBuilder = new AzureServiceBusTransportSettings();

            configurer.Register(c =>
            {
                var transport = new AzureServiceBusTransport(connectionString, inputQueueAddress);

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

                if (settingsBuilder.AutomaticPeekLockRenewalEnabled)
                {
                    transport.AutomaticallyRenewPeekLock();
                }

                return transport;
            });

            return settingsBuilder;
        }
        /// <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 asyncTaskFactory = c.Get<IAsyncTaskFactory>();
                    var transport = new BasicAzureServiceBusTransport(connectionString, inputQueueAddress, rebusLoggerFactory, asyncTaskFactory);

                    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 asyncTaskFactory = c.Get<IAsyncTaskFactory>();
                    var transport = new AzureServiceBusTransport(connectionString, inputQueueAddress, rebusLoggerFactory, asyncTaskFactory);

                    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;
        }