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