static void Register(StandardConfigurer<ISubscriptionStorage> configurer, string tableName, CloudStorageAccount storageAccount, bool isCentralized = false)
        {
            if (configurer == null) throw new ArgumentNullException(nameof(configurer));
            if (tableName == null) throw new ArgumentNullException(nameof(tableName));
            if (storageAccount == null) throw new ArgumentNullException(nameof(storageAccount));

            configurer.Register(c => new AzureStorageSubscriptionStorage(storageAccount, c.Get<IRebusLoggerFactory>(), isCentralized, tableName));
        }
コード例 #2
0
        static void Register(StandardConfigurer<ITransport> configurer, string inputQueueAddress, CloudStorageAccount storageAccount)
        {
            configurer.Register(c => new AzureStorageQueuesTransport(storageAccount, inputQueueAddress));

            configurer.OtherService<ITimeoutManager>().Register(c => new DisabledTimeoutManager(), description: AsqTimeoutManagerText);

            configurer.OtherService<IPipeline>().Decorate(c =>
            {
                var pipeline = c.Get<IPipeline>();
                
                return new PipelineStepRemover(pipeline)
                    .RemoveIncomingStep(s => s.GetType() == typeof(HandleDeferredMessagesStep));
            });
        }
コード例 #3
0
        static void Configure(StandardConfigurer<ITransport> configurer, string connectionString, string tableName, string inputQueueName)
        {
            configurer.Register(context =>
            {
                var connectionProvider = new DbConnectionProvider(connectionString);
                var transport = new SqlServerTransport(connectionProvider, tableName, inputQueueName);
                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));
            });
        }
コード例 #4
0
        /// <summary>
        /// Configures Rebus to use RabbitMQ to move messages around
        /// </summary>
        public static RabbitMqOptionsBuilder UseRabbitMq(this StandardConfigurer <ITransport> configurer, string connectionString, string inputQueueName)
        {
            var options = new RabbitMqOptionsBuilder();

            configurer
            .OtherService <RabbitMqTransport>()
            .Register(c =>
            {
                var rebusLoggerFactory = c.Get <IRebusLoggerFactory>();
                var transport          = new RabbitMqTransport(connectionString, inputQueueName, rebusLoggerFactory);
                options.Configure(transport);
                return(transport);
            });

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

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

            return(options);
        }
コード例 #5
0
        /// <summary>
        /// Configures Rebus to use MongoDB to store subscriptions. Use <see cref="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 StoreInMongoDb(this StandardConfigurer <ISubscriptionStorage> configurer, IMongoDatabase mongoDatabase, string collectionName, bool isCentralized = false)
        {
            if (configurer == null)
            {
                throw new ArgumentNullException("configurer");
            }
            if (mongoDatabase == null)
            {
                throw new ArgumentNullException("mongoDatabase");
            }
            if (collectionName == null)
            {
                throw new ArgumentNullException("collectionName");
            }

            configurer.Register(c =>
            {
                var subscriptionStorage = new MongoDbSubscriptionStorage(mongoDatabase, collectionName, isCentralized);

                return(subscriptionStorage);
            });
        }
コード例 #6
0
        /// <summary>
        /// Configures Rebus to use Amazon Simple Queue Service as the message transport
        /// </summary>
        public static void UseAmazonSqs(this StandardConfigurer <ITransport> configurer, string accessKeyId, string secretAccessKey, RegionEndpoint regionEndpoint, string inputQueueAddress)
        {
            configurer.Register(c =>
            {
                var rebusLoggerFactory = c.Get <IRebusLoggerFactory>();
                var asyncTaskFactory   = c.Get <IAsyncTaskFactory>();

                return(new AmazonSqsTransport(inputQueueAddress, accessKeyId, secretAccessKey, regionEndpoint, rebusLoggerFactory, asyncTaskFactory));
            });

            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);
        }
コード例 #7
0
        static void Configure(StandardConfigurer <ITransport> configurer, Func <IRebusLoggerFactory, IDbConnectionProvider> connectionProviderFactory, string tableName, string inputQueueName)
        {
            configurer.Register(context =>
            {
                var rebusLoggerFactory = context.Get <IRebusLoggerFactory>();
                var asyncTaskFactory   = context.Get <IAsyncTaskFactory>();
                var connectionProvider = connectionProviderFactory(rebusLoggerFactory);
                var transport          = new SqlServerTransport(connectionProvider, tableName, inputQueueName, rebusLoggerFactory, asyncTaskFactory);
                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 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);
            var sagaTypeNamingStrategy = GetSagaTypeNamingStrategy(c, rebusLoggerFactory);
            var serializer             = c.Has <ISagaSerializer>(false) ? c.Get <ISagaSerializer>() : new DefaultSagaSerializer();

            var sagaStorage = new SqlServerSagaStorage(connectionProvider, dataTableName, indexTableName, rebusLoggerFactory, sagaTypeNamingStrategy, serializer);

            if (automaticallyCreateTables)
            {
                sagaStorage.EnsureTablesAreCreated();
            }

            return(sagaStorage);
        });
    }
コード例 #9
0
    /// <summary>
    /// Configures the data bus to store data in the file system
    /// </summary>
    public static void StoreInFileSystem(this StandardConfigurer <IDataBusStorage> configurer, string directoryPath)
    {
        if (configurer == null)
        {
            throw new ArgumentNullException(nameof(configurer));
        }
        if (directoryPath == null)
        {
            throw new ArgumentNullException(nameof(directoryPath));
        }

        configurer.OtherService <FileSystemDataBusStorage>().Register(c =>
        {
            var rebusLoggerFactory = c.Get <IRebusLoggerFactory>();
            var rebusTime          = c.Get <IRebusTime>();

            return(new FileSystemDataBusStorage(directoryPath, rebusLoggerFactory, rebusTime));
        });

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

        configurer.OtherService <IDataBusStorageManagement>().Register(c => c.Get <FileSystemDataBusStorage>());
    }
コード例 #10
0
    /// <summary>
    /// Configures Rebus to use in-mem message queues, delivering/receiving from the specified <see cref="InMemNetwork"/>
    /// </summary>
    public static void UseInMemoryTransport(this StandardConfigurer <ITransport> configurer, InMemNetwork network, string inputQueueName)
    {
        if (configurer == null)
        {
            throw new ArgumentNullException(nameof(configurer));
        }
        if (network == null)
        {
            throw new ArgumentNullException(nameof(network));
        }
        if (inputQueueName == null)
        {
            throw new ArgumentNullException(nameof(inputQueueName));
        }

        configurer.OtherService <InMemTransport>()
        .Register(context => new InMemTransport(network, inputQueueName));

        configurer.OtherService <ITransportInspector>()
        .Register(context => context.Get <InMemTransport>());

        configurer.Register(context => context.Get <InMemTransport>());
    }
コード例 #11
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);
    }
コード例 #12
0
        /// <summary>Configures Rebus to use Apache Kafka to transport messages as a one-way client (i.e. will not be able to receive any messages).
        /// Performs a simplified configuration of the parameters of the producer used 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.</param>
        public static void UseKafkaAsOneWayClient(this StandardConfigurer <ITransport> configurer, string brokerList)
        {
            // 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, 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);
        }
コード例 #13
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 RabbitMqOptionsBuilder UseRabbitMqAsOneWayClient(this StandardConfigurer <ITransport> configurer, string connectionString)
        {
            var options = new RabbitMqOptionsBuilder();

            configurer
            .OtherService <RabbitMqTransport>()
            .Register(c =>
            {
                var rebusLoggerFactory = c.Get <IRebusLoggerFactory>();
                var transport          = new RabbitMqTransport(connectionString, null, 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);
        }
コード例 #14
0
 /// <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());
 }
コード例 #15
0
        static void Register(StandardConfigurer<ITransport> configurer, string inputQueueAddress, CloudStorageAccount storageAccount)
        {
            if (configurer == null) throw new ArgumentNullException(nameof(configurer));
            if (inputQueueAddress == null) throw new ArgumentNullException(nameof(inputQueueAddress));
            if (storageAccount == null) throw new ArgumentNullException(nameof(storageAccount));

            configurer.Register(c =>
            {
                var rebusLoggerFactory = c.Get<IRebusLoggerFactory>();
                return new AzureStorageQueuesTransport(storageAccount, inputQueueAddress, rebusLoggerFactory);
            });

            configurer.OtherService<ITimeoutManager>().Register(c => new DisabledTimeoutManager(), description: AsqTimeoutManagerText);

            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 a JSON file as the subscription storage
 /// </summary>
 public static void UseJsonFile(this StandardConfigurer <ISubscriptionStorage> configurer, string jsonFilePath)
 {
     configurer.Register(c => new JsonFileSubscriptionStorage(jsonFilePath));
 }
 static void Configure(StandardConfigurer<IDataBusStorage> configurer, string containerName, CloudStorageAccount cloudStorageAccount)
 {
     configurer.Register(c => new AzureBlobsDataBusStorage(cloudStorageAccount,containerName, c.Get<IRebusLoggerFactory>()));
 }
コード例 #18
0
 /// <summary>
 /// Configures Rebus to use the simple and extremely fast Jil JSON serializer
 /// </summary>
 public static void UseJil(this StandardConfigurer <ISerializer> configurer)
 {
     configurer.Register(c => new JilSerializer());
 }
コード例 #19
0
 /// <summary>
 /// Configures Rebus to output saga snapshots to the log. Each saga data mutation will be logged as a serialized JSON object without type information
 /// with INFO level to the class-logger of <see cref="LoggerSagaSnapperShotter"/>.
 /// This is probably mostly useful in debugging scenarios, or as a simple auditing mechanism in cases where sagas don't expect a lot of traffic.
 /// </summary>
 public static void OutputToLog(this StandardConfigurer <ISagaSnapshotStorage> configurer)
 {
     configurer.Register(c => new LoggerSagaSnapperShotter(c.Get <IRebusLoggerFactory>()));
 }
コード例 #20
0
 static void Register(StandardConfigurer <ITransport> configurer, string inputQueueAddress, CloudStorageAccount storageAccount)
 {
     configurer.Register(c => new AzureStorageQueuesTransport(storageAccount, inputQueueAddress));
 }
コード例 #21
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)
        {
            configurer.Register(c => new InMemTransport(network, null));

            OneWayClientBackdoor.ConfigureOneWayClient(configurer);
        }
コード例 #22
0
 public static void MyRouting(this StandardConfigurer <IRouter> configurer)
 {
     configurer.Register(c => new MyRouter());
 }
コード例 #23
0
 /// <summary>
 /// Configures Rebus to use a combination of blob and table storage to store sagas
 /// </summary>
 public static void StoreInAzureStorage(this StandardConfigurer <ISagaStorage> configurer, CloudStorageAccount cloudStorageAccount,
                                        string tableName     = "RebusSagaIndex",
                                        string containerName = "RebusSagaStorage")
 {
     configurer.Register(c => new AzureStorageSagaStorage(cloudStorageAccount, c.Get <IRebusLoggerFactory>(), tableName, containerName));
 }
コード例 #24
0
        static void Configure(StandardConfigurer<IRouter> configurer)
        {
            var rebusRoutingConfigurationSection = GetRebusRoutingConfigurationSection();

            configurer.Register(c =>
            {
                var rebusLoggerFactory = c.Get<IRebusLoggerFactory>();
                var typeBasedRouter = new TypeBasedRouter(rebusLoggerFactory);

                SetUpEndpointMappings(rebusRoutingConfigurationSection.MappingsCollection, (type, endpoint) => typeBasedRouter.Map(type, endpoint));

                return typeBasedRouter;
            });
        }
コード例 #25
0
 static void Configure(StandardConfigurer <IDataBusStorage> configurer, string containerName, CloudStorageAccount cloudStorageAccount)
 {
     configurer.Register(c => new AzureBlobsDataBusStorage(cloudStorageAccount, containerName, c.Get <IRebusLoggerFactory>()));
 }
コード例 #26
0
 /// <summary>
 /// Configures Rebus to use Newtonsoft JSON.NET to serialize messages, using the specified <see cref="JsonSerializerSettings"/>.
 /// This allows you to customize almost every aspect of how messages are actually serialized/deserialized.
 /// </summary>
 public static void UseNewtonsoftJson(this StandardConfigurer <ISerializer> configurer, JsonSerializerSettings settings)
 {
     configurer.Register(c => new JsonSerializer(settings));
 }
コード例 #27
0
 /// <summary>
 /// Configures Rebus to store subscriptions in memory. The subscription storage is assumed to be DECENTRALIZED
 /// with this overload because NO <see cref="InMemorySubscriberStore"/> is passed in and subscriptions are therefore private
 /// for this endpoint.  PLEASE NOTE that this  is probably not useful for any other scenario  than TESTING because usually you want
 /// subscriptions to be PERSISTENT.
 /// </summary>
 public static void StoreInMemory(this StandardConfigurer <ISubscriptionStorage> configurer)
 {
     configurer.Register(c => new InMemorySubscriptionStorage());
 }
コード例 #28
0
 static void Register(StandardConfigurer<ITransport> configurer, string inputQueueAddress, CloudStorageAccount storageAccount)
 {
     configurer.Register(c => new AzureStorageQueuesTransport(storageAccount, inputQueueAddress));
 }
コード例 #29
0
 /// <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");
 }
コード例 #30
0
 /// <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));
 }
コード例 #31
0
 /// <summary>
 /// Configures Rebus to use the simple and really fast MsgPack serializer
 /// </summary>
 public static void UseMsgPack(this StandardConfigurer <ISerializer> configurer)
 {
     configurer.Register(c => new MsgPackSerializer());
 }
コード例 #32
0
 /// <summary>
 /// Configures Rebus to use in-mem message queues, delivering/receiving from the specified <see cref="InMemNetwork"/>
 /// </summary>
 public static void UseInMemoryTransport(this StandardConfigurer <ITransport> configurer, InMemNetwork network, string inputQueueName)
 {
     configurer.Register(context => new InMemTransport(network, inputQueueName));
 }
コード例 #33
0
 /// <summary>
 /// Configures Rebus to use MSMQ to transport messages, receiving messages from the specified <paramref name="inputQueueName"/>
 /// </summary>
 public static void UseMsmq(this StandardConfigurer <ITransport> configurer, string inputQueueName)
 {
     configurer.Register(context => new MsmqTransport(inputQueueName));
 }
コード例 #34
0
 /// <summary>
 /// Configures Rebus to use Amazon Simple Queue Service as the message transport
 /// </summary>
 public static void UseAmazonSqs(this StandardConfigurer <ITransport> configurer, string accessKeyId, string secretAccessKey, RegionEndpoint regionEndpoint, string inputQueueAddress)
 {
     configurer.Register(c => new AmazonSqsTransport(inputQueueAddress, accessKeyId, secretAccessKey, regionEndpoint));
 }
 /// <summary>
 /// Use RabbitMq with delayed plugin
 /// https://github.com/rabbitmq/rabbitmq-delayed-message-exchange
 /// </summary>
 /// <param name="configurer"></param>
 /// <param name="endpoint">RabbitMq endpoint</param>
 /// <param name="queueToBind">Queue to bind exchange</param>
 /// <param name="exchangeName">Exchange delayed name</param>
 public static void UseRabbitMqDelayed(this StandardConfigurer <ITimeoutManager> configurer, string endpoint, string queueToBind, string exchangeName)
 {
     configurer.Register(register => new RabbitMqDelayedMessageTimeout(endpoint, queueToBind, exchangeName));
 }