Example #1
0
        /// <summary>Detailed Rebus configuration to use Apache Kafka to transport messages as a one-way client (i.e. will not be able to receive any messages).
        /// Allows you to configure all the parameters of the producerused in this transport.</summary>
        /// <param name="configurer"></param>
        /// <param name="brokerList">Initial list of brokers as a CSV list of broker host or host:port.
        /// Overwrites 'bootstrap' values.server', possibly specified via producerConfig</param>
        /// <param name="producerConfig">A collection of librdkafka configuration parameters
        ///     (refer to https://github.com/edenhill/librdkafka/blob/master/CONFIGURATION.md)
        ///     and parameters specific to this client (refer to:
        ///     <see cref="T:Confluent.Kafka.ConfigPropertyNames" />).
        ///     At a minimum, 'bootstrap.servers' must be specified.</param>
        public static void UseKafkaAsOneWayClient(this StandardConfigurer <ITransport> configurer,
                                                  string brokerList, ProducerConfig producerConfig)
        {
            // Register implementation of the transport as ISubscriptionStorage as well
            configurer
            .OtherService <KafkaTransport>()
            .Register(c =>
            {
                var rebusLoggerFactory = c.Get <IRebusLoggerFactory>();
                var asyncTaskFactory   = c.Get <IAsyncTaskFactory>();
                var cancellationToken  = c.Get <CancellationToken>();
                return(new KafkaTransport(rebusLoggerFactory, asyncTaskFactory, brokerList
                                          , null, producerConfig, null, cancellationToken));
            });

            // Register implementation of the Transport as ITransport
            configurer.Register(c => c.Get <KafkaTransport>());

            // Link the ISubscriberStorage to the transport
            configurer
            .OtherService <ISubscriptionStorage>()
            .Register(c => c.Get <KafkaTransport>(), description: AsbSubStorageText);

            OneWayClientBackdoor.ConfigureOneWayClient(configurer);
        }
Example #2
0
        /// <summary>
        /// Configures Rebus to use Azure Storage Queues to transport messages as a one-way client (i.e. will not be able to receive any messages)
        /// </summary>
        public static void UseAzureStorageQueuesAsOneWayClient(this StandardConfigurer <ITransport> configurer, string accountName, string keyValue, bool useHttps)
        {
            var storageAccount = new CloudStorageAccount(new StorageCredentials(accountName, keyValue), useHttps);

            Register(configurer, null, storageAccount);

            OneWayClientBackdoor.ConfigureOneWayClient(configurer);
        }
Example #3
0
        /// <summary>
        /// Configures Rebus to use Azure Storage Queues to transport messages as a one-way client (i.e. will not be able to receive any messages)
        /// </summary>
        public static void UseAzureStorageQueuesAsOneWayClient(this StandardConfigurer <ITransport> configurer, string storageAccountConnectionStringOrName)
        {
            var storageAccount = AzureConfigurationHelper.GetStorageAccount(storageAccountConnectionStringOrName);

            Register(configurer, null, storageAccount);

            OneWayClientBackdoor.ConfigureOneWayClient(configurer);
        }
        /// <summary>
        /// Configures Rebus to use Azure Storage Queues to transport messages as a one-way client (i.e. will not be able to receive any messages)
        /// </summary>
        public static void UseAzureStorageQueuesAsOneWayClient(this StandardConfigurer <ITransport> configurer, string storageAccountConnectionString)
        {
            var storageAccount = CloudStorageAccount.Parse(storageAccountConnectionString);

            Register(configurer, null, storageAccount);

            OneWayClientBackdoor.ConfigureOneWayClient(configurer);
        }
Example #5
0
        /// <summary>
        /// Configures Rebus to use the file system to transport messages, as a one-way client. The specified <paramref name="baseDirectory"/> will be used as the base directory
        /// within which subdirectories will be created for each logical queue.
        /// </summary>
        public static void UseFileSystemAsOneWayClient(this StandardConfigurer <ITransport> configurer, string baseDirectory)
        {
            if (baseDirectory == null)
            {
                throw new ArgumentNullException(nameof(baseDirectory));
            }

            configurer.Register(context => new FileSystemTransport(baseDirectory, null, new FileSystemTransportOptions(), context.Get <IRebusTime>()));
            OneWayClientBackdoor.ConfigureOneWayClient(configurer);
        }
        /// <summary>
        /// Configures Rebus to use Amazon Simple Queue Service as the message transport
        /// </summary>
        public static void UseAmazonSqsAsOneWayClient(this StandardConfigurer <ITransport> configurer, string accessKeyId, string secretAccessKey, RegionEndpoint regionEndpoint)
        {
            configurer.Register(c =>
            {
                var rebusLoggerFactory = c.Get <IRebusLoggerFactory>();
                return(new AmazonSqsTransport(null, accessKeyId, secretAccessKey, regionEndpoint, rebusLoggerFactory));
            });

            OneWayClientBackdoor.ConfigureOneWayClient(configurer);
        }
        /// <summary>
        /// Configures Rebus to use MSMQ to transport messages as a one-way client (i.e. will not be able to receive any messages)
        /// </summary>
        public static void UseMsmqAsOneWayClient(this StandardConfigurer <ITransport> configurer)
        {
            configurer.Register(c =>
            {
                var rebusLoggerFactory = c.Get <IRebusLoggerFactory>();
                return(new MsmqTransport(null, rebusLoggerFactory));
            });

            OneWayClientBackdoor.ConfigureOneWayClient(configurer);
        }
        /// <summary>
        /// Configures Rebus to use Amazon Simple Queue Service as the message transport
        /// </summary>
        public static void UseAmazonSqsAsOneWayClient(this StandardConfigurer <ITransport> configurer, string accessKeyId, string secretAccessKey, AmazonSQSConfig amazonSqsConfig)
        {
            configurer.Register(c =>
            {
                var rebusLoggerFactory = c.Get <IRebusLoggerFactory>();
                var asyncTaskFactory   = c.Get <IAsyncTaskFactory>();

                return(new AmazonSqsTransport(null, accessKeyId, secretAccessKey, amazonSqsConfig, rebusLoggerFactory, asyncTaskFactory));
            });

            OneWayClientBackdoor.ConfigureOneWayClient(configurer);
        }
Example #9
0
    /// <summary>
    /// Configures Rebus to use in-mem message queues, configuring this instance to be a one-way client
    /// </summary>
    public static void UseInMemoryTransportAsOneWayClient(this StandardConfigurer <ITransport> configurer, InMemNetwork network)
    {
        if (configurer == null)
        {
            throw new ArgumentNullException(nameof(configurer));
        }
        if (network == null)
        {
            throw new ArgumentNullException(nameof(network));
        }

        configurer.Register(c => new InMemTransport(network, null));

        OneWayClientBackdoor.ConfigureOneWayClient(configurer);
    }
        /// <summary>
        /// Configures Rebus to use MSMQ to transport messages as a one-way client (i.e. will not be able to receive any messages)
        /// </summary>
        public static MsmqTransportConfigurationBuilder UseMsmqAsOneWayClient(this StandardConfigurer <ITransport> configurer)
        {
            var builder = new MsmqTransportConfigurationBuilder();

            configurer.Register(c =>
            {
                var rebusLoggerFactory = c.Get <IRebusLoggerFactory>();
                var transport          = new MsmqTransport(null, rebusLoggerFactory);
                builder.Configure(transport);
                return(transport);
            });

            OneWayClientBackdoor.ConfigureOneWayClient(configurer);

            return(builder);
        }
Example #11
0
        /// <summary>
        /// Configures Rebus to use RabbitMQ to transport messages as a one-way client (i.e. will not be able to receive any messages)
        /// </summary>
        public static void UseRabbitMqAsOneWayClient(this StandardConfigurer <ITransport> configurer, string connectionString)
        {
            configurer
            .OtherService <RabbitMqTransport>()
            .Register(c =>
            {
                var rebusLoggerFactory = c.Get <IRebusLoggerFactory>();
                return(new RabbitMqTransport(connectionString, null, rebusLoggerFactory));
            });

            configurer
            .OtherService <ISubscriptionStorage>()
            .Register(c => c.Get <RabbitMqTransport>(), description: RabbitMqSubText);

            configurer.Register(c => c.Get <RabbitMqTransport>());

            OneWayClientBackdoor.ConfigureOneWayClient(configurer);
        }
Example #12
0
    static TTransportOptions Configure <TTransportOptions>(StandardConfigurer <ITransport> configurer, TransportFactoryDelegate transportFactory, TTransportOptions transportOptions) where TTransportOptions : SqlServerTransportOptions
    {
        configurer.Register(context =>
        {
            if (transportOptions.IsOneWayClient)
            {
                OneWayClientBackdoor.ConfigureOneWayClient(configurer);
            }

            var connectionProvider = transportOptions.ConnectionProviderFactory(context);
            var transport          = transportFactory(context, connectionProvider, transportOptions.InputQueueName);
            if ((transportOptions.InputQueueName != null) && (transportOptions.EnsureTablesAreCreated == true))
            {
                transport.EnsureTableIsCreated();
            }

            return(transport);
        }
                            );

        configurer.OtherService <Options>().Decorate(c =>
        {
            var options = c.Get <Options>();

            // if the transport is a one-way client and no external timeout manager has been configured, set the
            // external timeout manager's address to this magic string, which we'll detect later on
            if (transportOptions.IsOneWayClient && string.IsNullOrWhiteSpace(options.ExternalTimeoutManagerAddressOrNull))
            {
                options.ExternalTimeoutManagerAddressOrNull = SqlServerTransport.MagicExternalTimeoutManagerAddress;
            }

            return(options);
        });

        return(transportOptions);
    }
        /// <summary>
        /// Configures Rebus to use SQL Server to transport messages as a one-way client (i.e. will not be able to receive any messages).
        /// The table specified by <paramref name="tableName"/> will be used to store messages.
        /// The message table will automatically be created if it does not exist.
        /// </summary>
        public static void UseSqlServerAsOneWayClient(this StandardConfigurer <ITransport> configurer, string connectionStringOrConnectionStringName, string tableName)
        {
            Configure(configurer, connectionStringOrConnectionStringName, tableName, null);

            OneWayClientBackdoor.ConfigureOneWayClient(configurer);
        }
        /// <summary>
        /// Configures Rebus to use PostgreSql to transport messages as a one-way client (i.e. will not be able to receive any messages).
        /// The table specified by <paramref name="tableName"/> will be used to store messages.
        /// The message table will automatically be created if it does not exist.
        /// </summary>
        public static void UsePostgreSqlAsOneWayClient(this StandardConfigurer <ITransport> configurer, string connectionStringOrConnectionStringName, string tableName)
        {
            Configure(configurer, loggerFactory => new PostgresConnectionHelper(connectionStringOrConnectionStringName), tableName, null);

            OneWayClientBackdoor.ConfigureOneWayClient(configurer);
        }
Example #15
0
 /// <summary>
 /// Configures Rebus to use PostgreSql to transport messages as a one-way client (i.e. will not be able to receive any messages).
 /// The table specified by <paramref name="tableName"/> will be used to store messages.
 /// The message table will automatically be created if it does not exist.
 /// </summary>
 public static void UsePostgreSqlAsOneWayClient(this StandardConfigurer <ITransport> configurer, IPostgresConnectionProvider connectionProvider, string tableName)
 {
     Configure(configurer, connectionProvider, tableName, null);
     OneWayClientBackdoor.ConfigureOneWayClient(configurer);
 }
        /// <summary>
        /// Configures Rebus to use in-mem message queues, configuring this instance to be a one-way client
        /// </summary>
        public static void UseInMemoryTransportAsOneWayClient(this StandardConfigurer <ITransport> configurer, InMemNetwork network)
        {
            configurer.Register(c => new InMemTransport(network, null));

            OneWayClientBackdoor.ConfigureOneWayClient(configurer);
        }
Example #17
0
        /// <summary>
        /// Configures Rebus to use Azure Storage Queues to transport messages as a one-way client (i.e. will not be able to receive any messages)
        /// </summary>
        public static void UseAzureStorageQueuesAsOneWayClient(this StandardConfigurer <ITransport> configurer, CloudStorageAccount storageAccount)
        {
            Register(configurer, null, storageAccount);

            OneWayClientBackdoor.ConfigureOneWayClient(configurer);
        }
Example #18
0
        /// <summary>
        /// Configures Rebus to use SQL Server to transport messages as a one-way client (i.e. will not be able to receive any messages).
        /// The table specified by <paramref name="tableName"/> will be used to store messages.
        /// The message table will automatically be created if it does not exist.
        /// </summary>
        public static void UseSqlServerAsOneWayClient(this StandardConfigurer <ITransport> configurer, string connectionStringOrConnectionStringName, string tableName)
        {
            Configure(configurer, loggerFactory => new DbConnectionProvider(connectionStringOrConnectionStringName, loggerFactory), tableName, null);

            OneWayClientBackdoor.ConfigureOneWayClient(configurer);
        }