Exemplo n.º 1
0
        public static Configuration SubscribeCommandSchedulerToEventBusFor <TAggregate>(this Configuration configuration) where TAggregate : class, IEventSourced
        {
            var consequenter = Consequenter.Create <IScheduledCommand <TAggregate> >(e =>
            {
                Task.Run(() => configuration.CommandScheduler <TAggregate>().Schedule(e)).Wait();
            });

            var subscription = configuration.EventBus.Subscribe(consequenter);

            configuration.RegisterForDisposal(subscription);

            return(configuration);
        }
Exemplo n.º 2
0
        public static IDisposable ScheduleCommandsWith <TAggregate>(
            this IEventBus bus,
            ICommandScheduler <TAggregate> scheduler)
            where TAggregate : class, IEventSourced
        {
            var consequenter = Consequenter.Create <IScheduledCommand <TAggregate> >(
                e =>
            {
                scheduler.Schedule(e).Wait();
            });

            return(bus.Subscribe(consequenter));
        }