public static IAsbOptions UseAzureServiceBusInOneWayClientMode(this RebusTransportConfigurer configurer,
                                                                       string connectionString)
        {
            IAsbOptions asbOptionsToReturn;

            if (ShouldEmulateAzureEnvironment(connectionString))
            {
                var sender = MsmqMessageQueue.Sender();
                configurer.UseSender(sender);
                asbOptionsToReturn = new NoopAsbOptions();
            }
            else
            {
                var sender = AzureServiceBusMessageQueue.Sender(connectionString);
                configurer.UseSender(sender);
                asbOptionsToReturn = new AsbOptions(sender);
            }

            var gag = new OneWayClientGag();

            configurer.UseReceiver(gag);
            configurer.UseErrorTracker(gag);

            return(asbOptionsToReturn);
        }
        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);
                }
                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 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 void Configure(RebusTransportConfigurer configurer, string connectionString, string inputQueueName,
                              string errorQueueName)
        {
            var azureServiceBusMessageQueue = new AzureServiceBusMessageQueue(connectionString, inputQueueName);

            configurer.UseSender(azureServiceBusMessageQueue);
            configurer.UseReceiver(azureServiceBusMessageQueue);
            configurer.UseErrorTracker(new ErrorTracker(errorQueueName));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Configures Rebus to run in one-way client mode, which means that the bus is capable only of sending messages.
        /// </summary>
        public static void UseMsmqInOneWayClientMode(this RebusTransportConfigurer configurer)
        {
            var msmqMessageQueue = MsmqMessageQueue.Sender();

            configurer.UseSender(msmqMessageQueue);
            var gag = new OneWayClientGag();

            configurer.UseReceiver(gag);
            configurer.UseErrorTracker(gag);
        }
Ejemplo n.º 6
0
        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));
        }
        /// <summary>
        /// Configures Rebus to run in one-way client mode, which means that the bus is capable only of sending messages.
        /// </summary>
        public static void UseTheFileSystemInOneWayClientMode(this RebusTransportConfigurer configurer, string baseDirectory)
        {
            var transport = FileSystemMessageQueue.Sender(baseDirectory);

            configurer.UseSender(transport);
            var gag = new OneWayClientGag();

            configurer.UseReceiver(gag);
            configurer.UseErrorTracker(gag);
        }
        public static RabbitMqOptions UseRabbitMqFromConfigWithLocalName(this RebusTransportConfigurer configurer, string connectionString, string separator)
        {
            var section = RebusConfigurationSection.LookItUp();

            section.VerifyPresenceOfInputQueueConfig();
            section.VerifyPresenceOfErrorQueueConfig();
            var hostname   = GetHostName();
            var inputQueue = string.Format("{0}{2}{1}", section.InputQueue, hostname, separator);
            var errorQueue = string.Format("{0}{2}{1}", section.ErrorQueue, hostname, separator);

            return(configurer.UseRabbitMq(connectionString, inputQueue, errorQueue));
        }
Ejemplo n.º 9
0
        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 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));
        }
        /// <summary>
        /// Configures Rebus to run in one-way client mode, which means that the bus is capable only of sending messages.
        /// </summary>
        public static SqlServerMessageQueueOptions UseSqlServerInOneWayClientMode(this RebusTransportConfigurer configurer, string connectionStringOrConnectionStringName, string MessageTableName)
        {
            var connectionStringToUse = Rebus.Shared.ConnectionStringUtil.GetConnectionStringToUse(connectionStringOrConnectionStringName);
            var sqlServerMessageQueue = SqlServerMessageQueue.Sender(connectionStringToUse, MessageTableName);

            configurer.UseSender(sqlServerMessageQueue);
            var gag = new OneWayClientGag();

            configurer.UseReceiver(gag);
            configurer.UseErrorTracker(gag);

            return(new SqlServerMessageQueueOptions(sqlServerMessageQueue));
        }
        static IAsbOptions 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(new NoopAsbOptions());
            }

            var azureServiceBusMessageQueue = new AzureServiceBusMessageQueue(connectionString, inputQueueName);

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

            azureServiceBusMessageQueue.EnsureQueueExists(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;
                };
            });

            return(new AsbOptions(azureServiceBusMessageQueue));
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Specifies that you want to use MSMQ to both send and receive messages. The input
        /// queue name will be deduced from the Rebus configuration section in the application
        /// configuration file. The input queue will be automatically created if it doesn't exist.
        /// </summary>
        public static void UseMsmqAndGetInputQueueNameFromAppConfig(this RebusTransportConfigurer configurer)
        {
            try
            {
                var section = RebusConfigurationSection.LookItUp();

                section.VerifyPresenceOfInputQueueConfig();
                section.VerifyPresenceOfErrorQueueConfig();

                var inputQueueName = section.InputQueue;
                var errorQueueName = section.ErrorQueue;

                DoIt(configurer, inputQueueName, errorQueueName);
            }
            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);
            }
        }
Ejemplo n.º 14
0
        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));
        }
Ejemplo n.º 15
0
        public static void UseAzureServiceBusInOneWayClientMode(this RebusTransportConfigurer configurer,
                                                                string connectionString)
        {
            if (ShouldEmulateAzureEnvironment(connectionString))
            {
                var sender = MsmqMessageQueue.Sender();
                configurer.UseSender(sender);
            }
            else
            {
                var sender = AzureServiceBusMessageQueue.Sender(connectionString);
                configurer.UseSender(sender);
            }

            var gag = new OneWayClientGag();

            configurer.UseReceiver(gag);
            configurer.UseErrorTracker(gag);
        }
Ejemplo n.º 16
0
        public static DataBusOptions UseDataBus(this RebusTransportConfigurer configurer)
        {
            if (configurer == null)
            {
                throw new ArgumentNullException("configurer");
            }
            if (configurer.Backbone == null)
            {
                throw new InvalidOperationException("configurer must have a backbone");
            }
            if (configurer.Backbone.SendMessages == null)
            {
                throw new DataBusConfigurationException("Define the transport for the messagebus first");
            }



            var dataBusConfigurer = configurer.Backbone.LoadFromRegistry(() => new DataBusConfigurer(configurer.Backbone));

            return(new DataBusOptions(dataBusConfigurer));
        }
Ejemplo n.º 17
0
        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);
        }
Ejemplo n.º 18
0
        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));
        }
Ejemplo n.º 19
0
 /// <summary>
 /// Configures the bus to use RabbitMQ as a send-only transport - i.e. the bus will only be able to send messages, and if RabbitMQ manages
 /// subscriptions it will be able to publish as well. Will connect to the Rabbit server specified by the supplied connection string. This
 /// configuration assumes that an exchange already exists named "Rebus", which will be used to send all messages.
 /// </summary>
 public static RabbitMqOptions UseRabbitMqInOneWayModeWithExistingExchange(this RebusTransportConfigurer configurer, string connectionString)
 {
     return(DoItOneWay(configurer, connectionString, false));
 }
 /// <summary>
 /// Specifies that you want to use Sql Server to both send and receive messages. The input
 /// queue will be automatically created if it doesn't exist.
 /// </summary>
 public static SqlServerMessageQueueOptions UseSqlServer(this RebusTransportConfigurer configurer, string connectionStringOrConnectionStringName, string MessageTableName, string inputQueue, string errorQueue)
 {
     return(DoIt(connectionStringOrConnectionStringName, configurer, MessageTableName, inputQueue, errorQueue));
 }
        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));
        }
 public void ConfigureOneWayClientMode(RebusTransportConfigurer configurer)
 {
     configurer.UseRabbitMqInOneWayMode(RabbitMqFixtureBase.ConnectionString);
 }
 /// <summary>
 /// Configures the bus to use RabbitMQ as the transport. Will connect to the Rabbit server specified by the supplied connection string,
 /// and will look up Rebus-specified settings in the Rebus configuration section in your app.config.
 /// </summary>
 public static RabbitMqOptions UseRabbitMqAndGetInputQueueNameFromAppConfig(this RebusTransportConfigurer configurer, string connectionString)
 {
     return(DoItWithAppConfig(configurer, connectionString));
 }
 /// <summary>
 /// Configures the bus to use RabbitMQ as the transport. Will connect to the Rabbit server specified by the supplied connection string,
 /// and will use the supplied queue names.
 /// </summary>
 public static RabbitMqOptions UseRabbitMq(this RebusTransportConfigurer configurer, string connectionString, string inputQueueName, string errorQueue)
 {
     return(DoIt(configurer, connectionString, inputQueueName, errorQueue));
 }
 /// <summary>
 /// Configures the bus to use RabbitMQ as a send-only transport - i.e. the bus will only be able to send messages, and if RabbitMQ manages
 /// subscriptions it will be able to publish as well. Will connect to the Rabbit server specified by the supplied connection string.
 /// </summary>
 public static RabbitMqOptions UseRabbitMqInOneWayMode(this RebusTransportConfigurer configurer, string connectionString)
 {
     return(DoItOneWay(configurer, connectionString));
 }
Ejemplo n.º 26
0
 /// <summary>
 /// Specifies that you want to use MSMQ to both send and receive messages. The input
 /// queue will be automatically created if it doesn't exist.
 /// </summary>
 public static void UseMsmq(this RebusTransportConfigurer configurer, string inputQueue, string errorQueue)
 {
     DoIt(configurer, inputQueue, errorQueue);
 }
Ejemplo n.º 27
0
 internal RabbitMqOptions(RabbitMqMessageQueue queue, RebusTransportConfigurer configurer)
 {
     this.queue      = queue;
     this.configurer = configurer;
 }
 public static IAsbOptions UseAzureServiceBus(this RebusTransportConfigurer configurer, string connectionString, string inputQueueName, string errorQueueName)
 {
     return(Configure(configurer, connectionString, inputQueueName, errorQueueName));
 }
 public static void UseAzureServiceBus(this RebusTransportConfigurer configurer, string connectionString, string inputQueueName, string errorQueueName)
 {
     Configure(configurer, connectionString, inputQueueName, errorQueueName);
 }
 public static RabbitMqOptions UseRabbitMqFromConfigWithLocalName(this RebusTransportConfigurer configurer, string connectionString)
 {
     return(configurer.UseRabbitMqFromConfigWithLocalName(connectionString, DEFAULT_SEPARATOR));
 }