コード例 #1
0
        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;
        }
コード例 #2
0
 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));
 }
コード例 #3
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);
        }
コード例 #4
0
        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);
        }
コード例 #5
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);
        }
コード例 #6
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));
        }
コード例 #7
0
        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));
        }
コード例 #8
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);
        }
コード例 #9
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);
                // 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;
                    };
                });
        }
コード例 #10
0
        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);
        }
コード例 #11
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));
        }