public static IServiceCollection AddOutbox(this IServiceCollection services, IConfiguration Configuration, Action <DbContextOptionsBuilder> dbContextOptions = null)
        {
            var options = new OutboxOptions();

            Configuration.GetSection(nameof(OutboxOptions)).Bind(options);
            services.Configure <OutboxOptions>(Configuration.GetSection(nameof(OutboxOptions)));

            switch (options.OutboxType.ToLowerInvariant())
            {
            case "efcore":
            case "ef":
                services.AddEfCoreOutboxStore(dbContextOptions);
                break;

            case "dapr":
                services.AddDaprOutbox(Configuration);
                break;

            case "mongo":
            case "mongodb":
                services.AddMongoDbOutbox(Configuration);
                break;

            default:
                throw new Exception($"Outbox type '{options.OutboxType}' is not supported");
            }

            services.AddSingleton <IOutboxListener, OutboxListener>();
            services.AddHostedService <OutboxProcessor>();

            return(services);
        }
        public OutboxProcessor(IEventListener eventListener, IOptions <OutboxOptions> options)
        {
            _eventListener = eventListener;
            _outboxOptions = options.Value;

            var client   = new MongoClient(options.Value.ConnectionString);
            var database = client.GetDatabase(options.Value.DatabaseName);

            _outboxMessages = database.GetCollection <OutboxMessage>(options.Value.CollectionName);
        }
예제 #3
0
        public static IServiceCollection AddOutbox(this IServiceCollection services, IConfiguration Configuration)
        {
            var options = new OutboxOptions();

            Configuration.GetSection(nameof(OutboxOptions)).Bind(options);
            services.Configure <OutboxOptions>(Configuration.GetSection(nameof(OutboxOptions)));

            services.AddSingleton <IOutboxListener, OutboxListener>();
            services.AddHostedService <OutboxProcessor>();

            return(services);
        }
예제 #4
0
        private static IServiceCollection AddOutbox(this IServiceCollection services, IConfiguration configuration)
        {
            var options = new OutboxOptions();

            configuration.GetSection(nameof(OutboxOptions)).Bind(options);
            services.Configure <OutboxOptions>(configuration.GetSection(nameof(OutboxOptions)));

            services.AddScoped <IOutboxListener, OutboxListener>();
            services.AddHostedService <OutboxProcessor>();

            return(services);
        }
예제 #5
0
 public OutboxProcessor(IServiceScopeFactory serviceScopeFactory, IOptions <OutboxOptions> options, IEventListener eventListener)
 {
     _serviceScopeFactory = serviceScopeFactory;
     _eventListener       = eventListener;
     _outboxOptions       = options.Value;
 }
예제 #6
0
 public OutboxProcessor(IServiceScopeFactory serviceScopeFactory, OutboxOptions outboxOptions, IMessageBroker outbox)
 {
     _serviceScopeFactory = serviceScopeFactory;
     _outbox        = outbox;
     _outboxOptions = outboxOptions;
 }
예제 #7
0
 public OutboxProcessor(IEventListener eventListener, IOptions <OutboxOptions> options, IOutboxStore store)
 {
     _eventListener = eventListener;
     _store         = store;
     _outboxOptions = options.Value;
 }