static RabbitMqOptions DoIt(RebusTransportConfigurer configurer, string connectionString, string inputQueueName, string errorQueueName)
        {
            var queue = new RabbitMqMessageQueue(connectionString, inputQueueName);
            var options = new RabbitMqOptions(queue, configurer);

            configurer.AddDecoration(d =>
                {
                    if (options.CreateErrorQueue)
                    {
                        queue.CreateQueue(errorQueueName, true);
                    }
                    else
                    {
                        log.Info(
                            "Error queue matching topic '{0}' will NOT be created - please ensure that you have bound this topic to something, otherwise failed messages ARE LOST",
                            errorQueueName);
                    }
                });

            configurer.UseSender(queue);
            configurer.UseReceiver(queue);
            configurer.UseErrorTracker(new ErrorTracker(errorQueueName));

            return options;
        }
 static void Configure(RebusTransportConfigurer configurer, string connectionString, string inputQueueName,
                       string errorQueueName)
 {
     var azureServiceBusMessageQueue = new AzureServiceBusMessageQueue(connectionString, inputQueueName, errorQueueName);
     configurer.UseSender(azureServiceBusMessageQueue);
     configurer.UseReceiver(azureServiceBusMessageQueue);
     configurer.UseErrorTracker(new ErrorTracker(errorQueueName));
 }
        static void DoIt(RebusTransportConfigurer configurer, string baseDirectory, string inputQueueName, string errorQueueName)
        {
            var transport = new FileSystemMessageQueue(baseDirectory, inputQueueName);

            configurer.UseSender(transport);
            configurer.UseReceiver(transport);
            configurer.UseErrorTracker(new ErrorTracker(errorQueueName));
        }
        static RabbitMqOptions DoIt(RebusTransportConfigurer configurer, string connectionString, string inputQueueName, string errorQueueName, bool ensureExchangeIsDeclared)
        {
            var queue = new RabbitMqMessageQueue(connectionString, inputQueueName, ensureExchangeIsDeclared);

            configurer.UseSender(queue);
            configurer.UseReceiver(queue);
            configurer.UseErrorTracker(new ErrorTracker(errorQueueName));

            return new RabbitMqOptions(queue, configurer);
        }
        static RabbitMqOptions DoItWithAppConfig(RebusTransportConfigurer configurer, string connectionString, bool ensureExchangeIsDeclared)
        {
            try
            {
                var section = RebusConfigurationSection.LookItUp();

                var inputQueueName = section.InputQueue;

                if (string.IsNullOrEmpty(inputQueueName))
                {
                    throw new ConfigurationErrorsException(
                        "Could not get input queue name from Rebus configuration section. Did you forget the 'inputQueue' attribute?");
                }

                var errorQueueName = section.ErrorQueue;

                if (string.IsNullOrEmpty(errorQueueName))
                {
                    throw new ConfigurationErrorsException(
                        "Could not get input queue name from Rebus configuration section. Did you forget the 'errorQueue' attribute?");
                }

                return DoIt(configurer, connectionString, inputQueueName, errorQueueName, ensureExchangeIsDeclared);
            }
            catch (ConfigurationErrorsException e)
            {
                throw new ConfigurationException(
                    @"
            An error occurred when trying to parse out the configuration of the RebusConfigurationSection:

            {0}

            -

            For this way of configuring input queue to work, you need to supply a correct configuration section declaration in the <configSections> element of your app.config/web.config - like so:

            <configSections>
            <section name=""rebus"" type=""Rebus.Configuration.RebusConfigurationSection, Rebus"" />
            <!-- other stuff in here as well -->
            </configSections>

            -and then you need a <rebus> element some place further down the app.config/web.config, like so:

            <rebus inputQueue=""my.service.input.queue"" errorQueue=""my.service.error.queue"" />

            Note also, that specifying the input queue name with the 'inputQueue' attribute is optional.

            A more full example configuration snippet can be seen here:

            {1}
            ",
                    e, RebusConfigurationSection.ExampleSnippetForErrorMessages);
            }
        }
        static RabbitMqOptions DoItOneWay(RebusTransportConfigurer configurer, string connectionString)
        {
            var messageQueue = RabbitMqMessageQueue.Sender(connectionString);
            configurer.UseSender(messageQueue);

            var gag = new OneWayClientGag();
            configurer.UseReceiver(gag);
            configurer.UseErrorTracker(gag);

            return new RabbitMqOptions(messageQueue, configurer);
        }
        static RabbitMqOptions DoIt(RebusTransportConfigurer configurer, string connectionString, string inputQueueName, string errorQueueName)
        {
            var queue = new RabbitMqMessageQueue(connectionString, inputQueueName);

            configurer.AddDecoration(d => queue.CreateQueue(errorQueueName));

            configurer.UseSender(queue);
            configurer.UseReceiver(queue);
            configurer.UseErrorTracker(new ErrorTracker(errorQueueName));

            return new RabbitMqOptions(queue, configurer);
        }
        static void DoIt(RebusTransportConfigurer configurer, string inputQueueName, string errorQueueName)
        {
            if (string.IsNullOrEmpty(inputQueueName))
            {
                throw new ConfigurationErrorsException("You need to specify an input queue.");
            }

            var msmqMessageQueue = new MsmqMessageQueue(inputQueueName);

            var errorQueuePath = MsmqUtil.GetPath(errorQueueName);

            MsmqUtil.EnsureMessageQueueExists(errorQueuePath);
            MsmqUtil.EnsureMessageQueueIsTransactional(errorQueuePath);

            configurer.UseSender(msmqMessageQueue);
            configurer.UseReceiver(msmqMessageQueue);
            configurer.UseErrorTracker(new ErrorTracker(errorQueueName));
        }
Example #9
0
 public RabbitMqOptions(RabbitMqMessageQueue queue, RebusTransportConfigurer configurer)
 {
     this.queue = queue;
     this.configurer = configurer;
 }
        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);
        }
 public void ConfigureOneWayClientMode(RebusTransportConfigurer configurer)
 {
     configurer.UseRabbitMqInOneWayMode(RabbitMqFixtureBase.ConnectionString);
 }
        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;
                    };
                });
        }
Example #13
0
 public void ConfigureOneWayClientMode(RebusTransportConfigurer configurer)
 {
     configurer.UseMsmqInOneWayClientMode();
 }
        static SqlServerMessageQueueOptions DoIt(string connectionStringOrConnectionStringName, RebusTransportConfigurer configurer, string messageTableName, string inputQueueName, string errorQueueName)
        {
            var connectionStringToUse = Rebus.Shared.ConnectionStringUtil.GetConnectionStringToUse(connectionStringOrConnectionStringName);

            if (string.IsNullOrEmpty(inputQueueName))
            {
                throw new ConfigurationErrorsException("You need to specify an input queue.");
            }

            if(string.IsNullOrEmpty(messageTableName))
            {
                throw new ConfigurationException("You need to specify message table name.");
            }

            var sqlServerMessageQueue = new SqlServerMessageQueue(connectionStringToUse, messageTableName, inputQueueName);

            configurer.UseSender(sqlServerMessageQueue);
            configurer.UseReceiver(sqlServerMessageQueue);
            configurer.UseErrorTracker(new ErrorTracker(errorQueueName));

            return new SqlServerMessageQueueOptions(sqlServerMessageQueue);
        }
        static void DoIt(RebusTransportConfigurer configurer, string inputQueueName, string errorQueueName)
        {
            if (string.IsNullOrEmpty(inputQueueName))
            {
                throw new ConfigurationErrorsException("You need to specify an input queue.");
            }

            var msmqMessageQueue = new MsmqMessageQueue(inputQueueName);

            // since these operations only make sense to perform on a local queue, we'll skip it if the error queue is remote
            // (read http://blogs.msdn.com/b/johnbreakwell/archive/2008/07/31/checking-if-msmq-queues-exist-is-hard-work-so-should-you-bother.aspx
            // for more info...)
            if (MsmqUtil.IsLocal(errorQueueName))
            {
                var errorQueuePath = MsmqUtil.GetPath(errorQueueName);

                MsmqUtil.EnsureMessageQueueExists(errorQueuePath);
                MsmqUtil.EnsureMessageQueueIsTransactional(errorQueuePath);
            }

            configurer.UseSender(msmqMessageQueue);
            configurer.UseReceiver(msmqMessageQueue);
            configurer.UseErrorTracker(new ErrorTracker(errorQueueName));
        }