/// <summary> /// Configures Rebus to use Azure Service Bus to transport messages as a one-way client (i.e. will not be able to receive any messages) /// </summary> public static AzureServiceBusTransportClientSettings UseAzureServiceBusAsOneWayClient(this StandardConfigurer <ITransport> configurer, string connectionString) { var settingsBuilder = new AzureServiceBusTransportClientSettings(); configurer .OtherService <AzureServiceBusTransport>() .Register(c => { var cancellationToken = c.Get <CancellationToken>(); var rebusLoggerFactory = c.Get <IRebusLoggerFactory>(); var asyncTaskFactory = c.Get <IAsyncTaskFactory>(); var azureServiceBusNameHelper = c.Get <AzureServiceBusNameHelper>(); return(new AzureServiceBusTransport( connectionString: connectionString, queueName: null, rebusLoggerFactory: rebusLoggerFactory, asyncTaskFactory: asyncTaskFactory, azureServiceBusNameHelper: azureServiceBusNameHelper, cancellationToken: cancellationToken )); }); RegisterServices(configurer, () => settingsBuilder.LegacyNamingEnabled); OneWayClientBackdoor.ConfigureOneWayClient(configurer); return(settingsBuilder); }
/// <summary> /// Configures Rebus to use Azure Service Bus to transport messages as a one-way client (i.e. will not be able to receive any messages) /// </summary> public static void UseAzureServiceBusAsOneWayClient(this StandardConfigurer <ITransport> configurer, string connectionStringNameOrConnectionString, AzureServiceBusMode mode = AzureServiceBusMode.Standard) { var connectionString = GetConnectionString(connectionStringNameOrConnectionString); if (mode == AzureServiceBusMode.Basic) { configurer.Register(c => { var rebusLoggerFactory = c.Get <IRebusLoggerFactory>(); var asyncTaskFactory = c.Get <IAsyncTaskFactory>(); return(new BasicAzureServiceBusTransport(connectionString, null, rebusLoggerFactory, asyncTaskFactory)); }); OneWayClientBackdoor.ConfigureOneWayClient(configurer); return; } configurer .OtherService <AzureServiceBusTransport>() .Register(c => { var rebusLoggerFactory = c.Get <IRebusLoggerFactory>(); var asyncTaskFactory = c.Get <IAsyncTaskFactory>(); return(new AzureServiceBusTransport(connectionString, null, rebusLoggerFactory, asyncTaskFactory)); }); configurer .OtherService <ISubscriptionStorage>() .Register(c => c.Get <AzureServiceBusTransport>(), description: AsbSubStorageText); configurer.Register(c => c.Get <AzureServiceBusTransport>()); configurer.OtherService <ITimeoutManager>().Register(c => new DisabledTimeoutManager(), description: AsbTimeoutManagerText); OneWayClientBackdoor.ConfigureOneWayClient(configurer); }
private static RabbitMqOptionsBuilder BuildInternal(StandardConfigurer <ITransport> configurer, bool oneway, Func <IResolutionContext, RabbitMqOptionsBuilder, RabbitMqTransport> rabbitMqTransportBuilder) { if (configurer == null) { throw new ArgumentNullException(nameof(configurer)); } var options = new RabbitMqOptionsBuilder(); configurer .OtherService <RabbitMqTransport>() .Register(c => { var transport = rabbitMqTransportBuilder(c, options); options.Configure(transport); return(transport); }); configurer .OtherService <ISubscriptionStorage>() .Register(c => c.Get <RabbitMqTransport>(), description: RabbitMqSubText); configurer.Register(c => c.Get <RabbitMqTransport>()); if (oneway) { OneWayClientBackdoor.ConfigureOneWayClient(configurer); } return(options); }
/// <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 RabbitMqOptionsBuilder UseRabbitMqAsOneWayClient(this StandardConfigurer <ITransport> configurer, string connectionString) { if (configurer == null) { throw new ArgumentNullException(nameof(configurer)); } if (connectionString == null) { throw new ArgumentNullException(nameof(connectionString)); } var options = new RabbitMqOptionsBuilder(); configurer .OtherService <RabbitMqTransport>() .Register(c => { string explicitlyOmittedQueueName = null; var rebusLoggerFactory = c.Get <IRebusLoggerFactory>(); var transport = new RabbitMqTransport(connectionString, explicitlyOmittedQueueName, rebusLoggerFactory); options.Configure(transport); return(transport); }); configurer .OtherService <ISubscriptionStorage>() .Register(c => c.Get <RabbitMqTransport>(), description: RabbitMqSubText); configurer.Register(c => c.Get <RabbitMqTransport>()); OneWayClientBackdoor.ConfigureOneWayClient(configurer); return(options); }
/// <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); }
/// <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, AzureStorageQueuesTransportOptions options = null) { var storageAccount = CloudStorageAccount.Parse(storageAccountConnectionString); Register(configurer, null, storageAccount, options); OneWayClientBackdoor.ConfigureOneWayClient(configurer); }
/// <summary> /// Configures Rebus to use Amazon Simple Queue Service as the message transport /// </summary> static void UseAmazonSqsAsOneWayClient(StandardConfigurer <ITransport> configurer, AWSCredentials credentials, AmazonSQSConfig amazonSqsConfig, AmazonSQSTransportOptions options = null) { configurer.Register(c => { var rebusLoggerFactory = c.Get <IRebusLoggerFactory>(); var asyncTaskFactory = c.Get <IAsyncTaskFactory>(); return(new AmazonSqsTransport(null, credentials, amazonSqsConfig, rebusLoggerFactory, asyncTaskFactory, options)); }); OneWayClientBackdoor.ConfigureOneWayClient(configurer); }
/// <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 message table will automatically be created if it does not exist. /// </summary> public static void UseSqlServerAsOneWayClient(this StandardConfigurer <ITransport> configurer, string connectionStringOrConnectionStringName #if NET45 , bool enlistInAmbientTransaction = false #endif ) { Configure(configurer, loggerFactory => new DbConnectionProvider(connectionStringOrConnectionStringName, loggerFactory #if NET45 , enlistInAmbientTransaction #endif ), null, (context, provider, inputQueue) => new SqlServerTransport(provider, inputQueue, context.Get <IRebusLoggerFactory>(), context.Get <IAsyncTaskFactory>())); OneWayClientBackdoor.ConfigureOneWayClient(configurer); }
/// <summary> /// Configures Rebus to use SQL Server as its transport (in "one-way client mode", i.e. as a send-only endpoint). Unlike the <c>UseSqlServer</c> calls the leased version of the SQL /// Server transport does not hold a transaction open for the entire duration of the message handling. Instead it marks a /// message as being "leased" for a period of time. If the lease has expired then a worker is permitted to acquire the that /// message again and try reprocessing /// </summary> /// <param name="configurer">Static to extend</param> /// <param name="connectionStringOrConnectionStringName">Connection string or the named connection</param> /// <param name="leaseInterval">If <c>null</c> will default to <seealso cref="SqlServerLeaseTransport.DefaultLeaseTime"/>. Specifies how long a worker will request to keep a message. Higher values require less database communication but increase latency of a message being processed if a worker dies</param> /// <param name="leaseTolerance">If <c>null</c> defaults to <seealso cref="SqlServerLeaseTransport.DefaultLeaseTolerance"/>. Workers will wait for this amount of time to elapse, beyond the lease time, before they pick up an already leased message.</param> /// <param name="automaticallyRenewLeases">If <c>true</c> then workers will automatically renew the lease they have acquired whilst they're still processing the message. This will occur in accordance with <paramref name="leaseAutoRenewInterval"/></param> /// <param name="leaseAutoRenewInterval">If <c>null</c> defaults to <seealso cref="SqlServerLeaseTransport.DefaultLeaseAutomaticRenewal"/>. Specifies how frequently a lease will be renewed whilst the worker is processing a message. Lower values decrease the chance of other workers processing the same message but increase DB communication. A value 50% of <paramref name="leaseInterval"/> should be appropriate</param> /// <param name="leasedByFactory">If non-<c>null</c> a factory which returns a string identifying this worker when it leases a message. If <c>null></c> the current machine name is used</param> /// <param name="enlistInAmbientTransaction">If <c>true</c> the connection will be enlisted in the ambient transaction if it exists, else it will create an SqlTransaction and enlist in it</param> public static void UseSqlServerInLeaseModeAsOneWayClient(this StandardConfigurer <ITransport> configurer, string connectionStringOrConnectionStringName, TimeSpan?leaseInterval = null, TimeSpan?leaseTolerance = null, bool automaticallyRenewLeases = false, TimeSpan?leaseAutoRenewInterval = null, Func <string> leasedByFactory = null #if NET45 , bool enlistInAmbientTransaction = false #endif ) { ConfigureInLeaseMode(configurer, loggerFactory => new DbConnectionProvider(connectionStringOrConnectionStringName, loggerFactory #if NET45 , enlistInAmbientTransaction #endif ), null, leaseInterval, leaseTolerance, automaticallyRenewLeases, leaseAutoRenewInterval); OneWayClientBackdoor.ConfigureOneWayClient(configurer); }
static TTransportOptions Configure <TTransportOptions>(StandardConfigurer <ITransport> configurer, TransportFactoryDelegate transportFactory, TTransportOptions transportOptions) where TTransportOptions : SqlServerTransportOptions { configurer.Register(context => { if (transportOptions.IsOneWayQueue == true) { 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 <ITimeoutManager>().Register(c => new DisabledTimeoutManager(), @"A timeout manager cannot be explicitly configured when using SQL Server as the transport. This is because because the SQL transport has built-in deferred message capabilities, and therefore it is not necessary to configure anything else to be able to delay message delivery."); configurer.OtherService <IPipeline>().Decorate(c => { var pipeline = c.Get <IPipeline>(); return(new PipelineStepRemover(pipeline) .RemoveIncomingStep(s => s.GetType() == typeof(HandleDeferredMessagesStep))); }); configurer.OtherService <Options>().Decorate(c => { var options = c.Get <Options>(); if (string.IsNullOrWhiteSpace(options.ExternalTimeoutManagerAddressOrNull)) { options.ExternalTimeoutManagerAddressOrNull = SqlServerTransport.MagicExternalTimeoutManagerAddress; } return(options); }); return(transportOptions); }
/// <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); }
static void ConfigureOneWayClient(StandardConfigurer <ITransport> configurer, AWSCredentials credentials, AmazonSQSConfig amazonSqsConfig, AmazonSQSTransportOptions options) { if (configurer == null) { throw new ArgumentNullException(nameof(configurer)); } if (credentials == null) { throw new ArgumentNullException(nameof(credentials)); } if (amazonSqsConfig == null) { throw new ArgumentNullException(nameof(amazonSqsConfig)); } if (options == null) { throw new ArgumentNullException(nameof(options)); } configurer.Register(c => { var rebusLoggerFactory = c.Get <IRebusLoggerFactory>(); var asyncTaskFactory = c.Get <IAsyncTaskFactory>(); return(new AmazonSQSTransport(null, credentials, amazonSqsConfig, rebusLoggerFactory, asyncTaskFactory, options)); }); OneWayClientBackdoor.ConfigureOneWayClient(configurer); if (options.UseNativeDeferredMessages) { configurer .OtherService <IPipeline>() .Decorate(p => { var pipeline = p.Get <IPipeline>(); return(new PipelineStepRemover(pipeline) .RemoveIncomingStep(s => s.GetType() == typeof(HandleDeferredMessagesStep))); }); configurer.OtherService <ITimeoutManager>() .Register(c => new DisabledTimeoutManager(), description: SqsTimeoutManagerText); } }
/// <summary> /// Configures Rebus to use Azure Service Bus to transport messages as a one-way client (i.e. will not be able to receive any messages) /// </summary> public static AzureServiceBusTransportClientSettings UseAzureServiceBusAsOneWayClient(this StandardConfigurer <ITransport> configurer, string connectionString, ITokenProvider tokenProvider = null) { var settingsBuilder = new AzureServiceBusTransportClientSettings(); configurer.OtherService <Options>().Decorate(c => { var options = c.Get <Options>(); options.ExternalTimeoutManagerAddressOrNull = AzureServiceBusTransport.MagicDeferredMessagesAddress; return(options); }); configurer .OtherService <AzureServiceBusTransport>() .Register(c => { var cancellationToken = c.Get <CancellationToken>(); var rebusLoggerFactory = c.Get <IRebusLoggerFactory>(); var asyncTaskFactory = c.Get <IAsyncTaskFactory>(); var nameFormatter = c.Get <INameFormatter>(); var transport = new AzureServiceBusTransport( connectionString: connectionString, queueName: null, rebusLoggerFactory: rebusLoggerFactory, asyncTaskFactory: asyncTaskFactory, nameFormatter: nameFormatter, cancellationToken: cancellationToken, tokenProvider: tokenProvider ); transport.MaximumMessagePayloadBytes = settingsBuilder.MaximumMessagePayloadBytes; return(transport); }); RegisterServices(configurer, () => settingsBuilder.LegacyNamingEnabled); OneWayClientBackdoor.ConfigureOneWayClient(configurer); return(settingsBuilder); }
/// <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) { if (configurer == null) { throw new ArgumentNullException(nameof(configurer)); } var builder = new MsmqTransportConfigurationBuilder(); configurer.Register(c => { var rebusLoggerFactory = c.Get <IRebusLoggerFactory>(); var extensionDeserializer = c.Has <IMsmqHeaderSerializer>(false) ? c.Get <IMsmqHeaderSerializer>() : new ExtensionHeaderSerializer(); var transport = new MsmqTransport(null, rebusLoggerFactory, extensionDeserializer); builder.Configure(transport); return(transport); }); OneWayClientBackdoor.ConfigureOneWayClient(configurer); return(builder); }
/// <summary> /// Configures Rebus to use Google Pub/Sub to transport messages as a one-way client (i.e. will not be able to receive any messages) /// </summary> public static void UseGooglePubSubAsOneWayClient(this StandardConfigurer <ITransport> configurer, ICloudQueueFactory queueFactory, GooglePubSubTransportOptions options = null) { Register(configurer, null, queueFactory, options); OneWayClientBackdoor.ConfigureOneWayClient(configurer); }
/// <summary> /// Configures Rebus to use Oracle 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 UseOracleAQAsOneWayClient(this StandardConfigurer <ITransport> configurer, string connectionStringOrConnectionStringName, OracleAQTransportOptions options, bool enlistInAmbientTransaction = false) { ConfigureAQ(configurer, loggerFactory => new OracleConnectionHelper(connectionStringOrConnectionStringName, enlistInAmbientTransaction), options); OneWayClientBackdoor.ConfigureOneWayClient(configurer); }
/// <summary> /// Configures Rebus to use SQL Server as its transport (in "one-way client mode", i.e. as a send-only endpoint). The message table will automatically be created if it does not exist. /// </summary> /// <param name="configurer">Static to extend</param> /// <param name="connectionFactory">Factory to provide a new connection</param> /// <param name="leaseInterval">If <c>null</c> will default to <seealso cref="SqlServerLeaseTransport.DefaultLeaseTime"/>. Specifies how long a worker will request to keep a message. Higher values require less database communication but increase latency of a message being processed if a worker dies</param> /// <param name="leaseTolerance">If <c>null</c> defaults to <seealso cref="SqlServerLeaseTransport.DefaultLeaseTolerance"/>. Workers will wait for this amount of time to elapse, beyond the lease time, before they pick up an already leased message.</param> /// <param name="automaticallyRenewLeases">If <c>true</c> then workers will automatically renew the lease they have acquired whilst they're still processing the message. This will occur in accordance with <paramref name="leaseAutoRenewInterval"/></param> /// <param name="leaseAutoRenewInterval">If <c>null</c> defaults to <seealso cref="SqlServerLeaseTransport.DefaultLeaseAutomaticRenewal"/>. Specifies how frequently a lease will be renewed whilst the worker is processing a message. Lower values decrease the chance of other workers processing the same message but increase DB communication. A value 50% of <paramref name="leaseInterval"/> should be appropriate</param> /// <param name="leasedByFactory">If non-<c>null</c> a factory which returns a string identifying this worker when it leases a message. If <c>null></c> the current machine name is used</param> public static void UseSqlServerInLeaseModeAsOneWayClient(this StandardConfigurer <ITransport> configurer, Func <Task <IDbConnection> > connectionFactory, TimeSpan?leaseInterval = null, TimeSpan?leaseTolerance = null, bool automaticallyRenewLeases = false, TimeSpan?leaseAutoRenewInterval = null, Func <string> leasedByFactory = null) { ConfigureInLeaseMode(configurer, loggerFactory => new DbConnectionFactoryProvider(connectionFactory, loggerFactory), null, leaseInterval, leaseTolerance, automaticallyRenewLeases, leaseAutoRenewInterval); OneWayClientBackdoor.ConfigureOneWayClient(configurer); }
/// <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 message table will automatically be created if it does not exist. /// </summary> public static void UseSqlServerAsOneWayClient(this StandardConfigurer <ITransport> configurer, Func <Task <IDbConnection> > connectionFactory) { Configure(configurer, loggerFactory => new DbConnectionFactoryProvider(connectionFactory, loggerFactory), 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, IPostgresConnectionProvider connectionProvider, string tableName) { Configure(configurer, connectionProvider, tableName, null); OneWayClientBackdoor.ConfigureOneWayClient(configurer); }
/// <summary> /// Configures Rebus to use MySql 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 connectionString, string tableName) { Configure(configurer, loggerFactory => new MySqlConnectionHelper(connectionString), tableName, null); OneWayClientBackdoor.ConfigureOneWayClient(configurer); }
/// <summary> /// Configures Rebus to use Oracle 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 UseOracleAsOneWayClient(this StandardConfigurer <ITransport> configurer, string connectionStringOrConnectionStringName, string tableName) { Configure(configurer, loggerFactory => new OracleConnectionHelper(connectionStringOrConnectionStringName), tableName, null); 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, ICloudQueueFactory queueFactory, AzureStorageQueuesTransportOptions options = null) { Register(configurer, null, queueFactory, options); 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, CloudStorageAccount storageAccount, AzureStorageQueuesTransportOptions options = null) { Register(configurer, null, storageAccount, options); OneWayClientBackdoor.ConfigureOneWayClient(configurer); }
/// <summary> /// Configures Rebus to use Oracle 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 UseOracleAsOneWayClient(this StandardConfigurer <ITransport> configurer, string connectionStringOrConnectionStringName, string tableName, bool enlistInAmbientTransaction = false, bool automaticallyCreateTables = true) { Configure(configurer, loggerFactory => new OracleConnectionHelper(connectionStringOrConnectionStringName, enlistInAmbientTransaction), tableName, null, automaticallyCreateTables); OneWayClientBackdoor.ConfigureOneWayClient(configurer); }
/// <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); }