static void Configure(StandardConfigurer <ITransport> configurer, IPostgresConnectionProvider connectionProvider, string tableName, string inputQueueName) { configurer.Register(context => { var rebusLoggerFactory = context.Get <IRebusLoggerFactory>(); var asyncTaskFactory = context.Get <IAsyncTaskFactory>(); var rebusTime = context.Get <IRebusTime>(); var transport = new PostgreSqlTransport(connectionProvider, tableName, inputQueueName, rebusLoggerFactory, asyncTaskFactory, rebusTime); transport.EnsureTableIsCreated(); return(transport); }); configurer.OtherService <ITimeoutManager>().Register(c => new DisabledTimeoutManager()); configurer.OtherService <IPipeline>().Decorate(c => { var pipeline = c.Get <IPipeline>(); return(new PipelineStepRemover(pipeline) .RemoveIncomingStep(s => s.GetType() == typeof(HandleDeferredMessagesStep))); }); }
/// <summary> /// Configures Rebus to use SQL Server to store subscriptions. Use <paramref name="isCentralized"/> = true to indicate whether it's OK to short-circuit /// subscribing and unsubscribing by manipulating the subscription directly from the subscriber or just let it default to false to preserve the /// default behavior. /// </summary> public static void StoreInSqlServer(this StandardConfigurer <ISubscriptionStorage> configurer, string connectionStringOrConnectionStringName, string tableName, bool isCentralized = false, bool automaticallyCreateTables = true #if NET45 , bool enlistInAmbientTransaction = false #endif ) { if (configurer == null) { throw new ArgumentNullException(nameof(configurer)); } if (connectionStringOrConnectionStringName == null) { throw new ArgumentNullException(nameof(connectionStringOrConnectionStringName)); } if (tableName == null) { throw new ArgumentNullException(nameof(tableName)); } configurer.Register(c => { var rebusLoggerFactory = c.Get <IRebusLoggerFactory>(); var connectionProvider = new DbConnectionProvider(connectionStringOrConnectionStringName, rebusLoggerFactory #if NET45 , enlistInAmbientTransaction #endif ); var subscriptionStorage = new SqlServerSubscriptionStorage(connectionProvider, tableName, isCentralized, rebusLoggerFactory); if (automaticallyCreateTables) { subscriptionStorage.EnsureTableIsCreated(); } return(subscriptionStorage); }); }
static void RegisterServices(StandardConfigurer <ITransport> configurer, Func <bool> legacyNamingEnabled) { // map ITransport to transport implementation configurer.Register(c => c.Get <AzureServiceBusTransport>()); // map subscription storage to transport configurer .OtherService <ISubscriptionStorage>() .Register(c => c.Get <AzureServiceBusTransport>(), description: AsbSubStorageText); // disable timeout manager configurer.OtherService <ITimeoutManager>().Register(c => new DisabledTimeoutManager(), description: AsbTimeoutManagerText); configurer.OtherService <INameFormatter>().Register(c => { // lazy-evaluated setting because the builder needs a chance to be built upon before getting its settings var useLegacyNaming = legacyNamingEnabled(); if (useLegacyNaming) { return(new LegacyNameFormatter()); } else { return(new DefaultNameFormatter()); } }); configurer.OtherService <DefaultAzureServiceBusTopicNameConvention>().Register(c => { // lazy-evaluated setting because the builder needs a chance to be built upon before getting its settings var useLegacyNaming = legacyNamingEnabled(); return(new DefaultAzureServiceBusTopicNameConvention(useLegacyNaming: useLegacyNaming)); }); configurer.OtherService <ITopicNameConvention>().Register(c => c.Get <DefaultAzureServiceBusTopicNameConvention>()); }
static void ConfigureOneWayClient(StandardConfigurer <ITransport> configurer, AmazonSQSTransportOptions options) { if (configurer == null) { throw new ArgumentNullException(nameof(configurer)); } if (options == null) { throw new ArgumentNullException(nameof(options)); } configurer.Register(c => { var rebusLoggerFactory = c.Get <IRebusLoggerFactory>(); var asyncTaskFactory = c.Get <IAsyncTaskFactory>(); var rebusTime = c.Get <IRebusTime>(); return(new AmazonSqsTransport(null, rebusLoggerFactory, asyncTaskFactory, options, rebusTime)); }); 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 SQL Server to store sagas, using the tables specified to store data and indexed properties respectively. /// </summary> public static void StoreInSqlServer(this StandardConfigurer <ISagaStorage> configurer, string connectionString, string dataTableName, string indexTableName, bool automaticallyCreateTables = true, bool enlistInAmbientTransaction = false ) { if (configurer == null) { throw new ArgumentNullException(nameof(configurer)); } if (connectionString == null) { throw new ArgumentNullException(nameof(connectionString)); } if (dataTableName == null) { throw new ArgumentNullException(nameof(dataTableName)); } if (indexTableName == null) { throw new ArgumentNullException(nameof(indexTableName)); } configurer.Register(c => { var rebusLoggerFactory = c.Get <IRebusLoggerFactory>(); var connectionProvider = new DbConnectionProvider(connectionString, rebusLoggerFactory, enlistInAmbientTransaction); var sagaTypeNamingStrategy = GetSagaTypeNamingStrategy(c, rebusLoggerFactory); var sagaStorage = new SqlServerSagaStorage(connectionProvider, dataTableName, indexTableName, rebusLoggerFactory, sagaTypeNamingStrategy); if (automaticallyCreateTables) { sagaStorage.EnsureTablesAreCreated(); } return(sagaStorage); }); }
/// <summary> /// Configures Rebus to use MySQL to store sagas, using the tables specified to store data and indexed properties respectively. /// </summary> public static void StoreInMySql(this StandardConfigurer <ISagaStorage> configurer, Func <Task <IDbConnection> > connectionFactory, string dataTableName, string indexTableName, bool automaticallyCreateTables = true) { if (configurer == null) { throw new ArgumentNullException(nameof(configurer)); } if (connectionFactory == null) { throw new ArgumentNullException(nameof(connectionFactory)); } if (dataTableName == null) { throw new ArgumentNullException(nameof(dataTableName)); } if (indexTableName == null) { throw new ArgumentNullException(nameof(indexTableName)); } configurer.Register(c => { var rebusLoggerFactory = c.Get <IRebusLoggerFactory>(); var connectionProvider = new DbConnectionFactoryProvider(connectionFactory); var sagaTypeNamingStrategy = GetSagaTypeNamingStrategy(c, rebusLoggerFactory); var serializer = c.Has <ISagaSerializer>(false) ? c.Get <ISagaSerializer>() : new DefaultSagaSerializer(); var sagaStorage = new MySqlSagaStorage(connectionProvider, dataTableName, indexTableName, rebusLoggerFactory, sagaTypeNamingStrategy, serializer); if (automaticallyCreateTables) { sagaStorage.EnsureTablesAreCreated(); } return(sagaStorage); }); }
/// <summary> /// Configures Rebus to use MSMQ to transport messages, receiving messages from the specified <paramref name="inputQueueName"/> /// </summary> public static MsmqTransportConfigurationBuilder UseMsmq(this StandardConfigurer <ITransport> configurer, string inputQueueName) { if (configurer == null) { throw new ArgumentNullException(nameof(configurer)); } if (inputQueueName == null) { throw new ArgumentNullException(nameof(inputQueueName)); } var builder = new MsmqTransportConfigurationBuilder(); configurer.Register(c => { var rebusLoggerFactory = c.Get <IRebusLoggerFactory>(); var transport = new MsmqTransport(inputQueueName, rebusLoggerFactory); builder.Configure(transport); return(transport); }); return(builder); }
/// <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) { var connectionString = GetConnectionString(connectionStringNameOrConnectionString); 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); }
/// <summary> /// Configures Rebus to use SQL Server to store sagas, using the tables specified to store data and indexed properties respectively. /// </summary> public static void StoreInSqlServer(this StandardConfigurer<ISagaStorage> configurer, Func<Task<IDbConnection>> connectionFactory, string dataTableName, string indexTableName, bool automaticallyCreateTables = true) { if (configurer == null) throw new ArgumentNullException(nameof(configurer)); if (connectionFactory == null) throw new ArgumentNullException(nameof(connectionFactory)); if (dataTableName == null) throw new ArgumentNullException(nameof(dataTableName)); if (indexTableName == null) throw new ArgumentNullException(nameof(indexTableName)); configurer.Register(c => { var rebusLoggerFactory = c.Get<IRebusLoggerFactory>(); var connectionProvider = new DbConnectionFactoryProvider(connectionFactory, rebusLoggerFactory); var sagaStorage = new SqlServerSagaStorage(connectionProvider, dataTableName, indexTableName, rebusLoggerFactory); if (automaticallyCreateTables) { sagaStorage.EnsureTablesAreCreated(); } return sagaStorage; }); }
public static EtcdConfigurationBuilder UseEtcd(this StandardConfigurer <IRouter> configurer, string url) { if (configurer == null) { throw new ArgumentNullException(nameof(configurer)); } if (url == null) { throw new ArgumentNullException(nameof(url)); } var typeHelper = new TypeHelper(); var configurationBuilder = new EtcdConfigurationBuilder(typeHelper); configurer.OtherService <EtcdClient>().Register(c => { var etcdClient = new EtcdClient(url); var transport = c.Get <ITransport>(); configurationBuilder.Initialize(etcdClient, transport); return(etcdClient); }); configurer.OtherService <EtcdRouter>().Register(c => { var etcdClient = c.Get <EtcdClient>(); return(new EtcdRouter(etcdClient, typeHelper)); }); configurer.Register(c => c.Get <EtcdRouter>()); configurer.OtherService <ISubscriptionStorage>().Register(c => c.Get <EtcdRouter>()); return(configurationBuilder); }
/// <summary> /// Configures Rebus to use MySQL to store subscriptions. Use <paramref name="isCentralized"/> = true to indicate whether it's OK to short-circuit /// subscribing and unsubscribing by manipulating the subscription directly from the subscriber or just let it default to false to preserve the /// default behavior. /// </summary> public static void StoreInMySql(this StandardConfigurer <ISubscriptionStorage> configurer, string connectionString, string tableName, bool isCentralized = false, bool automaticallyCreateTables = true) { configurer.Register(c => { var rebusLoggerFactory = c.Get <IRebusLoggerFactory>(); var connectionHelper = new MySqlConnectionHelper(connectionString); var subscriptionStorage = new MySqlSubscriptionStorage( connectionHelper, tableName, isCentralized, rebusLoggerFactory); if (automaticallyCreateTables) { var createTableTask = subscriptionStorage.EnsureTableIsCreated(); createTableTask.Wait(); // wait at least 1min to make sure the tables are correctly created. if (createTableTask.Exception != null) { throw createTableTask.Exception; } } return(subscriptionStorage); }); }
/// <summary> /// Configures Rebus to use Azure Service Bus queues to transport messages, connecting to the service bus instance pointed to by the connection string /// (or the connection string with the specified name from the current app.config) /// </summary> public static AzureServiceBusTransportSettings UseAzureServiceBus(this StandardConfigurer <ITransport> configurer, string connectionStringNameOrConnectionString, string inputQueueAddress) { var connectionString = GetConnectionString(connectionStringNameOrConnectionString); var settingsBuilder = new AzureServiceBusTransportSettings(); configurer.Register(c => { var transport = new AzureServiceBusTransport(connectionString, inputQueueAddress); if (settingsBuilder.PrefetchingEnabled) { transport.PrefetchMessages(settingsBuilder.NumberOfMessagesToPrefetch); } if (settingsBuilder.AutomaticPeekLockRenewalEnabled) { transport.AutomaticallyRenewPeekLock(); } return(transport); }); return(settingsBuilder); }
static void Configure(StandardConfigurer <ITransport> configurer, Func <IRebusLoggerFactory, IDbConnectionProvider> connectionProviderFactory, string inputQueueName, TransportFactoryDelegate transportFactory) { configurer.Register(context => { var rebusLoggerFactory = context.Get <IRebusLoggerFactory>(); var connectionProvider = connectionProviderFactory(rebusLoggerFactory); var transport = transportFactory(context, connectionProvider, inputQueueName); if (inputQueueName != null) { transport.EnsureTableIsCreated(); } return(transport); }); configurer.OtherService <ITimeoutManager>().Register(c => new DisabledTimeoutManager()); 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); }); }
/// <summary> /// Configures Rebus to use the super-spiffy Hyperion serializer to serialize messages /// </summary> public static void UseHyperion(this StandardConfigurer <ISerializer> configurer) { configurer.Register(c => new HyperionSerializer(), "HyperionSerializer was registered as the primary implementation of ISerializer"); }
/// <summary> /// Configures Rebus to use the Protobuf serializer with the default protobuf-net settings (i.e. with the <see cref="RuntimeTypeModel.Default"/> instance /// of the <see cref="RuntimeTypeModel"/>, requiring you to either decorate your type with appropriate <see cref="ProtoMemberAttribute"/> or /// supplying appropriate metadata to the default instance) /// </summary> public static void UseProtobuf(this StandardConfigurer <ISerializer> configurer) { configurer.Register(c => new ProtobufSerializer()); }
/// <summary> /// Configures Rebus to use the Protobuf serializer with the given <see cref="RuntimeTypeModel"/>, requiring you to either decorate your type with /// appropriate <see cref="ProtoMemberAttribute"/> or supplying appropriate metadata to the instance passed in) /// </summary> public static void UseProtobuf(this StandardConfigurer <ISerializer> configurer, RuntimeTypeModel runtimeTypeModel) { configurer.Register(c => new ProtobufSerializer(runtimeTypeModel)); }
public static StandardConfigurer <IOutboxContextFactory> Use(this StandardConfigurer <IOutboxContextFactory> configurer, Func <IOutboxContext> factory) { configurer.Register(c => new LambdaOutboxContextFactory(factory)); return(configurer); }
static void Configure(StandardConfigurer <ISubscriptionStorage> configurer, Func <IAmazonS3> amazonS3Factory, AmazonS3DataBusOptions options) { configurer.Register(c => new AmazonS3SubscriptionsStorage(amazonS3Factory, options)); }
static void Configure(StandardConfigurer <ISubscriptionStorage> configurer, AWSCredentials credentials, AmazonS3Config config, AmazonS3DataBusOptions options) { configurer.Register(c => new AmazonS3SubscriptionsStorage(credentials, config, options)); }
static void Configure(StandardConfigurer <IDataBusStorage> configurer, string containerName, CloudStorageAccount cloudStorageAccount) { configurer.Register(c => new AzureBlobsDataBusStorage(cloudStorageAccount, containerName, c.Get <IRebusLoggerFactory>())); }
/// <summary> /// Configures Rebus to use the super-spiffy Wire serializer to serialize messages /// </summary> public static void UseWire(this StandardConfigurer <ISerializer> configurer) { configurer.Register(c => new WireSerializer(), "Registered WireSerializer as the primary implementation of ISerializer"); }
private static void Configure(StandardConfigurer <IDataBusStorage> configurer, AWSCredentials credentials, AmazonS3Config config, AmazonS3DataBusOptions options, TransferUtilityConfig transferUtilityConfig) { configurer.Register(c => new AmazonS3DataBusStorage(credentials, config, options, transferUtilityConfig, c.Get <IRebusLoggerFactory>())); }
private static void Configure(StandardConfigurer <ISubscriptionStorage> configurer, Func <IAmazonS3> amazonS3Factory, AmazonS3DataBusOptions options) { configurer.Register(c => new AmazonS3SubscriptionsStorage(amazonS3Factory, options, c.Get <IRebusLoggerFactory>())); }
private static void Configure(StandardConfigurer <ISubscriptionStorage> configurer, AWSCredentials credentials, AmazonS3Config config, AmazonS3DataBusOptions options) { configurer.Register(c => new AmazonS3SubscriptionsStorage(credentials, config, options, c.Get <IRebusLoggerFactory>())); }
/// <summary> /// Configures Rebus to use Azure Service Bus queues to transport messages, connecting to the service bus instance pointed to by the connection string /// (or the connection string with the specified name from the current app.config) /// </summary> public static AzureServiceBusTransportSettings UseAzureServiceBus(this StandardConfigurer <ITransport> configurer, string connectionStringNameOrConnectionString, string inputQueueAddress, AzureServiceBusMode mode = AzureServiceBusMode.Standard) { var connectionString = GetConnectionString(connectionStringNameOrConnectionString); var settingsBuilder = new AzureServiceBusTransportSettings(); if (mode == AzureServiceBusMode.Basic) { configurer.Register(c => { var rebusLoggerFactory = c.Get <IRebusLoggerFactory>(); var transport = new BasicAzureServiceBusTransport(connectionString, inputQueueAddress, rebusLoggerFactory); if (settingsBuilder.PrefetchingEnabled) { transport.PrefetchMessages(settingsBuilder.NumberOfMessagesToPrefetch); } transport.AutomaticallyRenewPeekLock = settingsBuilder.AutomaticPeekLockRenewalEnabled; transport.PartitioningEnabled = settingsBuilder.PartitioningEnabled; return(transport); }); return(settingsBuilder); } configurer .OtherService <AzureServiceBusTransport>() .Register(c => { var rebusLoggerFactory = c.Get <IRebusLoggerFactory>(); var transport = new AzureServiceBusTransport(connectionString, inputQueueAddress, rebusLoggerFactory); if (settingsBuilder.PrefetchingEnabled) { transport.PrefetchMessages(settingsBuilder.NumberOfMessagesToPrefetch); } transport.AutomaticallyRenewPeekLock = settingsBuilder.AutomaticPeekLockRenewalEnabled; transport.PartitioningEnabled = settingsBuilder.PartitioningEnabled; return(transport); }); configurer .OtherService <ISubscriptionStorage>() .Register(c => c.Get <AzureServiceBusTransport>(), description: AsbSubStorageText); configurer.Register(c => c.Get <AzureServiceBusTransport>()); configurer.OtherService <IPipeline>().Decorate(c => { var pipeline = c.Get <IPipeline>(); return(new PipelineStepRemover(pipeline) .RemoveIncomingStep(s => s.GetType() == typeof(HandleDeferredMessagesStep))); }); configurer.OtherService <ITimeoutManager>().Register(c => new DisabledTimeoutManager(), description: AsbTimeoutManagerText); return(settingsBuilder); }