static void Configure(RebusTransportConfigurer configurer, string connectionString, string inputQueueName, string errorQueueName) { if (connectionString == null) { throw new ArgumentNullException("connectionString", "You need to specify a connection string in order to configure Rebus to use Azure Service Bus as the transport. If you want to simulate Azure Service Bus by using MSMQ, you may use 'UseDevelopmentStorage=true' as the connection string."); } if (ShouldEmulateAzureEnvironment(connectionString)) { log.Info("Azure Service Bus configuration has detected that development storage should be used - for the"); configurer.UseMsmq(inputQueueName, errorQueueName); return; } var azureServiceBusMessageQueue = new AzureServiceBusMessageQueue(connectionString, inputQueueName); configurer.UseSender(azureServiceBusMessageQueue); configurer.UseReceiver(azureServiceBusMessageQueue); configurer.UseErrorTracker(new ErrorTracker(errorQueueName)); azureServiceBusMessageQueue.GetOrCreateSubscription(errorQueueName); }
static void Configure(RebusTransportConfigurer configurer, string connectionString, string inputQueueName, string errorQueueName) { if (connectionString == null) { throw new ArgumentNullException("connectionString", "You need to specify a connection string in order to configure Rebus to use Azure Service Bus as the transport. If you want to simulate Azure Service Bus by using MSMQ, you may use 'UseDevelopmentStorage=true' as the connection string."); } if (ShouldEmulateAzureEnvironment(connectionString)) { log.Info("Azure Service Bus configuration has detected that development storage should be used - for the"); configurer.UseMsmq(inputQueueName, errorQueueName); // when we're emulating with MSMQ, we make this noop action available to allow user code to pretend to renew the peek lock configurer .Backbone .ConfigureEvents(e => { e.MessageContextEstablished += (bus, context) => { var noop = (Action)(() => log.Info("Azure Service Bus message peek lock would be renewed at this time")); context.Items[AzureServiceBusMessageQueue.AzureServiceBusRenewLeaseAction] = noop; }; }); return; } var azureServiceBusMessageQueue = new AzureServiceBusMessageQueue(connectionString, inputQueueName); configurer.UseSender(azureServiceBusMessageQueue); configurer.UseReceiver(azureServiceBusMessageQueue); configurer.UseErrorTracker(new ErrorTracker(errorQueueName)); azureServiceBusMessageQueue.GetOrCreateSubscription(errorQueueName); // transfer renew-peek-lock-action from transaction context to message context configurer .Backbone .ConfigureEvents(e => { e.MessageContextEstablished += (bus, context) => { var renewAction = TransactionContext.Current[AzureServiceBusMessageQueue.AzureServiceBusRenewLeaseAction]; context.Items[AzureServiceBusMessageQueue.AzureServiceBusRenewLeaseAction] = renewAction; }; }); }