Exemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="InprocEventProviderCommandBus"/> class.
 /// </summary>
 /// <param name="serviceLocator">命令提供者</param>
 /// <param name="eventStorager">领域事件的保存方案</param>
 /// <param name="commandStorager">命令储存</param>
 public InprocEventProviderCommandBus(IServiceLocator serviceLocator,
                                      IEventStorager eventStorager,
                                      ICommandStorager commandStorager)
     : base(serviceLocator)
 {
     this.eventBus        = new InprocEventBus(this, serviceLocator);
     this.eventStorager   = eventStorager ?? EmptyEventStreamStorager.Empty;
     this.commandStorager = commandStorager ?? EmptyCommandStreamStorager.Empty;
 }
Exemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RecoveryCommandBus"/> class.
 /// </summary>
 /// <param name="serviceLocator">命令提供者</param>
 /// <param name="eventStreamTypeStorager">领域事件的保存方案</param>
 /// <param name="commandStorager">命令储存</param>
 /// <param name="eventBusCallBack">命令总线初始回调</param>
 protected RecoveryCommandBus(IServiceLocator serviceLocator,
                              IEventStorager eventStreamTypeStorager,
                              ICommandStorager commandStorager,
                              System.Func <RecoveryCommandBus, IServiceLocator, IEventBus> eventBusCallBack)
     : base(serviceLocator)
 {
     this.eventBus        = eventBusCallBack(this, serviceLocator);
     this.eventStorager   = eventStreamTypeStorager ?? EmptyEventStreamStorager.Empty;
     this.commandStorager = commandStorager ?? EmptyCommandStreamStorager.Empty;
 }
Exemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RecoveryCommandBus"/> class.
 /// </summary>
 /// <param name="serviceLocator">命令提供者</param>
 /// <param name="recoveryStorager">事件存储</param>
 /// <param name="eventStorager">领域事件的保存方案</param>
 /// <param name="commandStorager">命令储存</param>
 public RecoveryCommandBus(IServiceLocator serviceLocator,
                           IEventStorager eventStorager,
                           ICommandStorager commandStorager,
                           IFailRecoveryStorager recoveryStorager)
     : base(serviceLocator)
 {
     this.eventBus        = new RecoveryEventBus(this, serviceLocator, recoveryStorager);
     this.eventStorager   = eventStorager ?? EmptyEventStreamStorager.Empty;
     this.commandStorager = commandStorager ?? EmptyCommandStreamStorager.Empty;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="MQEventProviderCommandBus"/> class.
 /// </summary>
 /// <param name="serviceLocator">服务定位器</param>
 /// <param name="messageProducerProvider">根据事件去查询消息发布者</param>
 /// <param name="eventStorager">领域事件的保存方案</param>
 /// <param name="commandStorager">命令储存</param>
 public MQEventProviderCommandBus(IServiceLocator serviceLocator,
                                  IEventStorager eventStorager,
                                  ICommandStorager commandStorager,
                                  IMessageProducerProvider messageProducerProvider)
     : base(serviceLocator)
 {
     this.eventBus        = new MQEventBus(this, messageProducerProvider);
     this.eventStorager   = eventStorager ?? EmptyEventStreamStorager.Empty;
     this.commandStorager = commandStorager ?? EmptyCommandStreamStorager.Empty;
 }
Exemplo n.º 5
0
        public static ApplicationStartup UseMQEventProviderCommandBus <TCommandContext>(this ApplicationStartup startup, IMessageProducerProvider messageProducerProvider, IEventStorager eventStorager, ICommandStorager commandStorager) where TCommandContext : ICommandContext
        {
            if (startup.ServiceRegister == null)
            {
                return(startup);
            }

            if (startup.Items.ContainsKey("UseMQEventProviderCommandBus"))
            {
                return(startup);
            }

            if (startup.Items.Remove("UseInprocEventProviderCommandBus"))
            {
                throw new ArgumentNullException("系统已经注册同进程模式的命令总线了,两者不同共存");
            }

            /*注册发布事件*/
            startup.ServiceRegister.RegisterType(typeof(TCommandContext), typeof(ICommandContext), string.Empty, ComponentLifeStyle.Transient);
            startup.ServiceRegister.RegisterType(typeof(DefaultEventContext), typeof(IEventContext), string.Empty, ComponentLifeStyle.Transient);
            startup.ServiceRegister.RegisterInstance(messageProducerProvider ?? new DefaultMessageProducerProvider(), typeof(IMessageProducerProvider), string.Empty);
            startup.ServiceRegister.RegisterType(typeof(MQEventProviderCommandBus), typeof(ICommandBus), string.Empty, ComponentLifeStyle.Singleton);
            startup.ServiceRegister.RegisterInstance(eventStorager ?? EmptyEventStreamStorager.Empty, typeof(IEventStorager), string.Empty);
            startup.ServiceRegister.RegisterInstance(commandStorager ?? EmptyCommandStreamStorager.Empty, typeof(ICommandStorager), string.Empty);

            //注入handler类型的对象
            startup.UseInjectingCommandHandlerEventHandler(ComponentLifeStyle.Singleton);

            startup.Items["UseMQEventProviderCommandBus"] = "t";
            return(startup);
        }
Exemplo n.º 6
0
 public static ApplicationStartup UseMQEventProviderCommandBus <TCommandContext>(this ApplicationStartup startup, IMessageProducerProvider messageProducerProvider, IEventStorager eventStorager) where TCommandContext : ICommandContext
 {
     return(UseMQEventProviderCommandBus <TCommandContext>(startup, messageProducerProvider, eventStorager, EmptyCommandStreamStorager.Empty));
 }
Exemplo n.º 7
0
 public static ApplicationStartup UseInprocEventProviderCommandBus <TCommandContext>(this ApplicationStartup startup, IEventStorager eventStorager)
     where TCommandContext : ICommandContext
 {
     return(UseInprocEventProviderCommandBus <TCommandContext>(startup, eventStorager, EmptyCommandStreamStorager.Empty));
 }