public EventSubscriber(string subscriptionName, IHandlerProvider handlerProvider, string[] subEndPoints) { SubscriptionName = subscriptionName; HandlerProvider = handlerProvider; SubEndPoints = subEndPoints; _ReceiveWorkTasks = new List <Task>(); }
public static IMessageDispatcher Create(IHandlerProvider handlerProvider, string dispatcherName, params object[] args) { IMessageDispatcher messageDispatcher = ServiceLocator.Instance.GetService<IMessageDispatcher>(dispatcherName); IEnumerable handlers = handlerProvider.GetHandlers(); MethodInfo methodInfo = messageDispatcher.GetType().GetMethod("Register", BindingFlags.Public | BindingFlags.Instance); foreach (object handlerObject in handlers) { var handlerInterfaceTypeQuery = from p in handlerObject.GetType().GetInterfaces() where p.IsGenericType && p.GetGenericTypeDefinition().Equals(typeof(IHandler<>)) select p; if (handlerInterfaceTypeQuery != null) { foreach (var handlerInterfaceType in handlerInterfaceTypeQuery) { Type messageType = handlerInterfaceType.GetGenericTypeDefinition(); MethodInfo genericRegisterMethod = methodInfo.MakeGenericMethod(messageType); genericRegisterMethod.Invoke(messageDispatcher, new object[] { handlerObject }); } } } return messageDispatcher; }
public DomainEventSubscriber(string name, EQueueClientsConsumers.ConsumerSetting consumerSetting, string groupName, string subscribeTopic, IHandlerProvider handlerProvider) : base(groupName, consumerSetting, groupName, subscribeTopic) { HandlerProvider = handlerProvider; }
/// <summary> /// Parameterized constructor. /// </summary> public DefaultCommandExecutor(IHandlerProvider handerProvider, IHandlerRecordStore handlerStore, ITypeCodeProvider typeCodeProvider, ILoggerFactory loggerFactory) : base(handerProvider, handlerStore, typeCodeProvider, loggerFactory) { }
public EventSubscriber(IMessageQueueClient messageQueueClient, IHandlerProvider handlerProvider, ICommandBus commandBus, IMessagePublisher messagePublisher, string subscriptionName, TopicSubscription[] topicSubscriptions, string consumerId, ConsumerConfig consumerConfig = null) { ConsumerConfig = consumerConfig ?? ConsumerConfig.DefaultConfig; MessageQueueClient = messageQueueClient; HandlerProvider = handlerProvider; _topicSubscriptions = topicSubscriptions ?? new TopicSubscription[0]; _topicSubscriptions.Where(ts => ts.TagFilter != null) .ForEach(ts => { TagFilters.Add(ts.Topic, ts.TagFilter); }); ConsumerId = consumerId; SubscriptionName = subscriptionName; MessagePublisher = messagePublisher; CommandBus = commandBus; var loggerFactory = ObjectProviderFactory.GetService <ILoggerFactory>(); MessageProcessor = new MailboxProcessor(new DefaultProcessingMessageScheduler(), new OptionsWrapper <MailboxOption>(new MailboxOption { BatchCount = ConsumerConfig.MailboxProcessBatchCount }), loggerFactory.CreateLogger <MailboxProcessor>()); Logger = loggerFactory.CreateLogger(GetType().Name); }
public static IMessageDispatcher Create(IHandlerProvider handlerProvider, string dispatcherName, params object[] args) { IMessageDispatcher messageDispatcher = ServiceLocator.Instance.GetService <IMessageDispatcher>(dispatcherName); IEnumerable handlers = handlerProvider.GetHandlers(); MethodInfo methodInfo = messageDispatcher.GetType().GetMethod("Register", BindingFlags.Public | BindingFlags.Instance); foreach (object handlerObject in handlers) { var handlerInterfaceTypeQuery = from p in handlerObject.GetType().GetInterfaces() where p.IsGenericType && p.GetGenericTypeDefinition().Equals(typeof(IHandler <>)) select p; if (handlerInterfaceTypeQuery != null) { foreach (var handlerInterfaceType in handlerInterfaceTypeQuery) { Type messageType = handlerInterfaceType.GetGenericTypeDefinition(); MethodInfo genericRegisterMethod = methodInfo.MakeGenericMethod(messageType); genericRegisterMethod.Invoke(messageDispatcher, new object[] { handlerObject }); } } } return(messageDispatcher); }
public CommandProcessorFactory( IHandlerProvider <TSession, TConnection> handlerProvider, ICommandExecutor <TConnection> commandExecutor ) { _handlerProvider = handlerProvider ?? throw new ArgumentNullException(nameof(handlerProvider)); _commandExecutor = commandExecutor ?? throw new ArgumentNullException(nameof(commandExecutor)); }
public EventSubscriber(string subscriptionName, IHandlerProvider handlerProvider, string[] subEndPoints) : base(handlerProvider, subscriptionName) { SubEndPoints = subEndPoints; _ReceiveWorkTasks = new List <Task>(); MessageQueue = new BlockingCollection <IMessageContext>(); _Logger = IoCFactory.Resolve <ILoggerFactory>().Create(this.GetType()); }
public CommandConsumer(IHandlerProvider handlerProvider, string receiveEndPoint) : base(handlerProvider) { MessageQueue = new BlockingCollection <IMessageContext>(); ReceiveEndPoint = receiveEndPoint; ReplySenders = new Dictionary <string, ZmqSocket>(); _Logger = IoCFactory.Resolve <ILoggerFactory>().Create(this.GetType()); }
public NotificationPublisher( IHandlerProvider <TSession, TConnection> handlerProvider, INotificationExecutor <TSession> executor ) { _handlerProvider = handlerProvider ?? throw new ArgumentNullException(nameof(handlerProvider)); _executor = executor ?? throw new ArgumentNullException(nameof(executor)); }
public QueryProcessor( IHandlerProvider <TSession, TConnection> handlerProvider, IQueryExecutor <TConnection> executor ) { _handlerProvider = handlerProvider ?? throw new ArgumentNullException(nameof(handlerProvider)); _executor = executor ?? throw new ArgumentNullException(nameof(executor)); }
public EventSubscriber(string subscriptionName, IHandlerProvider handlerProvider, string[] subEndPoints) : base(handlerProvider, subscriptionName) { SubEndPoints = subEndPoints; _ReceiveWorkTasks = new List<Task>(); MessageQueue = new BlockingCollection<IMessageContext>(); _Logger = IoCFactory.Resolve<ILoggerFactory>().Create(this.GetType()); }
public RabbitMqEventBus(ConnectionFactory connectionFactory, IHandlerProvider handlerProvider, IMessageProvider messageProvider = null, INameProvider nameProvider = null) { connectionProvider = new ConnectionProvider(connectionFactory); subscriptionManager = new SubscriptionManager(); this.handlerProvider = handlerProvider; this.messageProvider = messageProvider ?? new JsonMessageProvider(); this.nameProvider = nameProvider ?? new DefaultQueueNameProvider(); }
public CommandConsumer(IHandlerProvider handlerProvider, string receiveEndPoint) : base(handlerProvider) { MessageQueue = new BlockingCollection<IMessageContext>(); ReceiveEndPoint = receiveEndPoint; ReplySenders = new Dictionary<string, ZmqSocket>(); _Logger = IoCFactory.Resolve<ILoggerFactory>().Create(this.GetType()); }
/// <summary> /// Mediator constructor /// </summary> /// <param name="provider">Event and query handlers provider</param> /// <param name="middlewareProvider">Event and query middlewares provider</param> /// <param name="eventDispatchStrategy">Event dispatching strategy to use</param> public Mediator(IHandlerProvider provider, IMiddlewareProvider middlewareProvider, IEventDispatchStrategy eventDispatchStrategy) { _queryHandlerProvider = provider; _eventHandlerProvider = provider; _eventDispatchStrategy = eventDispatchStrategy; _queryMiddlewareProvider = middlewareProvider; _eventMiddlewareProvider = middlewareProvider; }
public CommandConsumer(IHandlerProvider handlerProvider, string serviceBusConnectionString, string commandQueueName) : base(serviceBusConnectionString) { _handlerProvider = handlerProvider; _commandQueueName = commandQueueName; _replyProducers = new Dictionary <string, TopicClient>(); }
public CommandConsumer(IHandlerProvider handlerProvider, IMessagePublisher messagePublisher, string commandQueueName) { _commandQueueName = commandQueueName; _handlerProvider = handlerProvider; _messagePublisher = messagePublisher; _messageQueueClient = IoCFactory.Resolve<IMessageQueueClient>(); _logger = IoCFactory.Resolve<ILoggerFactory>().Create(this.GetType()); }
/// <summary> /// Parameterized Constructor. /// </summary> public MessageExecutor(IHandlerProvider handlerProvider, IHandlerRecordStore handlerStore, ITypeCodeProvider typeCodeProvider, ILoggerFactory loggerFactory) { this._handlerProvider = handlerProvider; this._handlerStore = handlerStore; this._typeCodeProvider = typeCodeProvider; this._logger = loggerFactory.GetOrCreate("Cqrs"); }
public CommandConsumer(IHandlerProvider handlerProvider, IMessagePublisher messagePublisher, string commandQueueName) { _commandQueueName = commandQueueName; _handlerProvider = handlerProvider; _messagePublisher = messagePublisher; _messageQueueClient = IoCFactory.Resolve <IMessageQueueClient>(); _logger = IoCFactory.Resolve <ILoggerFactory>().Create(this.GetType()); }
public EventSubscriber(string serviceBusConnectionString, IHandlerProvider handlerProvider, string subscriptionName, params string[] topics) : base(serviceBusConnectionString) { _handlerProvider = handlerProvider; _topics = topics; _subscriptionName = subscriptionName; _consumeWorkTasks = new List <Task>(); }
private static T GetHandlerFromObject <T>(object obj) where T : class { IHandlerProvider <T> handlerProvider = obj as IHandlerProvider <T>; if (handlerProvider != null) { return(handlerProvider.Handler); } return(obj as T); }
public EventSubscriber(string serviceBusConnectionString, IHandlerProvider handlerProvider, string subscriptionName, params string[] topics) : base(handlerProvider, subscriptionName) { _serviceBusClient = new ServiceBusClient(serviceBusConnectionString); _handlerProvider = handlerProvider; _topics = topics; _subscriptionName = subscriptionName; _consumeWorkTasks = new List<Task>(); }
/// <summary> /// Register an instance of IHandlerProvider which will provide handlers for raised events. /// Multiple handler providers may be registered. /// </summary> /// <param name="handlerProvider"></param> public void RegisterProvider(IHandlerProvider handlerProvider) { if (handlerProvider == null) { throw new ArgumentNullException(nameof(handlerProvider)); } if (_handlerProviders.Contains(handlerProvider)) { return; } _handlerProviders.Add(handlerProvider); }
public CommandConsumer(string name, EQueueClientsConsumers.ConsumerSetting consumerSetting, string groupName, string subscribeTopic, string brokerAddress, int producerBrokerPort, IHandlerProvider handlerProvider) : base(name, consumerSetting, groupName, subscribeTopic) { HandlerProvider = handlerProvider; var producerSetting = new EQueueClientsProducers.ProducerSetting(); producerSetting.BrokerAddress = brokerAddress; producerSetting.BrokerPort = producerBrokerPort; Producer = new EQueueClientsProducers.Producer(string.Format("{0}-Reply-Producer", name), producerSetting); CommandConsumers.Add(this); }
//public static async Task<T> HandleAsync<T>(this IHandlerProvider handlerProvider, IResolverSession session, // string scopeId, string actionId, object[] requests, CancellationToken cancellationToken) //{ // var actionBytes = new byte[4]; // actionBytes.AddBytes<int>(actionId, 4, 0); // return await HandleAsync<T>(handlerProvider, session, scopeId, actionBytes, requests, cancellationToken); //} public static async Task <T> HandleAsync <T>(this IHandlerProvider handlerProvider, IResolverSession session, string scopeId, string actionId, object[] requests, CancellationToken cancellationToken) { var parameterTypes = requests.Where(r => !(r is CancellationToken)).Select(r => r.GetType()).ToArray(); var returnType = typeof(T); var parameterHash = TypeHasher.GetMethodBytes(parameterTypes, returnType, t => t.Name); //var scopeBytes = Encoding.UTF8.GetBytes(scopeId); var actionHash = TypeHasher.CreateMD5Hash(Encoding.UTF8.GetBytes($"scope-{scopeId}:action-{actionId}"), parameterHash); var handler = handlerProvider.GetHandler(actionHash.ToByteArray()); return((T)await handler.HandleAsync(session, requests, cancellationToken)); }
public EventSubscriber(IMessageQueueClient messageQueueClient, IHandlerProvider handlerProvider, ICommandBus commandBus, IMessagePublisher messagePublisher, string subscriptionName, params string[] topics) { _MessageQueueClient = messageQueueClient; _handlerProvider = handlerProvider; _topics = topics; _subscriptionName = subscriptionName; _messagePublisher = messagePublisher; _commandBus = commandBus; _logger = IoCFactory.Resolve <ILoggerFactory>().Create(this.GetType()); }
public MethodProtocolHandler(IHandlerProvider handlerProvider, IResolverSession resolverSession) { if (handlerProvider == null) { throw new ArgumentNullException(nameof(handlerProvider)); } if (resolverSession == null) { throw new ArgumentNullException(nameof(resolverSession)); } this.handlerProvider = handlerProvider; //this.resolverSession = resolverSession; }
public EventSubscriber(IMessageQueueClient messageQueueClient, IHandlerProvider handlerProvider, ICommandBus commandBus, IMessagePublisher messagePublisher, string subscriptionName, params string[] topics) { _MessageQueueClient = messageQueueClient; _handlerProvider = handlerProvider; _topics = topics; _subscriptionName = subscriptionName; _messagePublisher = messagePublisher; _commandBus = commandBus; _logger = IoCFactory.Resolve<ILoggerFactory>().Create(this.GetType()); }
public EventSubscriber(IMessageQueueClient messageQueueClient, IHandlerProvider handlerProvider, ICommandBus commandBus, IMessagePublisher messagePublisher, string subscriptionName, string topic, string consumerId) { _MessageQueueClient = messageQueueClient; _handlerProvider = handlerProvider; _topic = topic; _consumerId = consumerId; _subscriptionName = subscriptionName; _messagePublisher = messagePublisher; _commandBus = commandBus; _messageProcessor = new MessageProcessor(new DefaultProcessingMessageScheduler <IMessageContext>()); _logger = IoCFactory.Resolve <ILoggerFactory>().Create(this.GetType()); }
public CommandConsumer(IMessageQueueClient messageQueueClient, IMessagePublisher messagePublisher, IHandlerProvider handlerProvider, string commandQueueName, string consumerId, ConsumerConfig consumerConfig = null) { _consumerConfig = consumerConfig ?? ConsumerConfig.DefaultConfig; _commandQueueName = commandQueueName; _handlerProvider = handlerProvider; _messagePublisher = messagePublisher; _consumerId = consumerId; _cancellationTokenSource = new CancellationTokenSource(); _messageQueueClient = messageQueueClient; _messageProcessor = new MessageProcessor(new DefaultProcessingMessageScheduler <IMessageContext>(), _consumerConfig.MailboxProcessBatchCount); _logger = IoCFactory.IsInit() ? IoCFactory.Resolve <ILoggerFactory>().Create(GetType().Name) : null; }
public PipelineBuilder( [NotNull]BusSettings busSettings, [NotNull]IHandlerProvider handlerProvider, [NotNull]IGlobalPipelineProvider globalPipelineProvider, [NotNull]IGlobalPipelineTracker tracker, [NotNull]IDependencyScope dependencyScope) { if (handlerProvider == null) throw new ArgumentNullException(nameof(handlerProvider)); if (globalPipelineProvider == null) throw new ArgumentNullException(nameof(globalPipelineProvider)); if (tracker == null) throw new ArgumentNullException(nameof(tracker)); if (dependencyScope == null) throw new ArgumentNullException(nameof(dependencyScope)); if (busSettings == null) throw new ArgumentNullException(nameof(busSettings)); this.handlerProvider = handlerProvider; this.globalPipelineProvider = globalPipelineProvider; this.tracker = tracker; this.dependencyScope = dependencyScope; this.busSettings = busSettings; }
public CommandConsumer(IMessageQueueClient messageQueueClient, IMessagePublisher messagePublisher, IHandlerProvider handlerProvider, string commandQueueName, string consumerId, int fullLoadThreshold = 1000, int waitInterval = 1000) { _fullLoadThreshold = fullLoadThreshold; _waitInterval = waitInterval; _commandQueueName = commandQueueName; _handlerProvider = handlerProvider; _messagePublisher = messagePublisher; _consuemrId = consumerId; _cancellationTokenSource = new CancellationTokenSource(); _messageQueueClient = messageQueueClient; _messageProcessor = new MessageProcessor(new DefaultProcessingMessageScheduler <IMessageContext>()); _logger = IoCFactory.Resolve <ILoggerFactory>().Create(this.GetType()); }
public EventSubscriber(IMessageQueueClient messageQueueClient, IHandlerProvider handlerProvider, ICommandBus commandBus, IMessagePublisher messagePublisher, string subscriptionName, string topic, string consumerId, ConsumerConfig consumerConfig = null) { _consumerConfig = consumerConfig ?? ConsumerConfig.DefaultConfig; _messageQueueClient = messageQueueClient; _handlerProvider = handlerProvider; _topic = topic; _consumerId = consumerId; _subscriptionName = subscriptionName; _messagePublisher = messagePublisher; _commandBus = commandBus; _messageProcessor = new MessageProcessor(new DefaultProcessingMessageScheduler <IMessageContext>(), _consumerConfig.MailboxProcessBatchCount); _logger = IoCFactory.IsInit() ? IoCFactory.Resolve <ILoggerFactory>().Create(GetType().Name) : null; }
public CommandProcessor(IMessageQueueClient messageQueueClient, IMessagePublisher messagePublisher, IHandlerProvider handlerProvider, string commandQueueName, string consumerId, ConsumerConfig consumerConfig = null) { ConsumerConfig = consumerConfig ?? ConsumerConfig.DefaultConfig; CommandQueueName = commandQueueName; HandlerProvider = handlerProvider; MessagePublisher = messagePublisher; ConsumerId = consumerId; CancellationTokenSource = new CancellationTokenSource(); MessageQueueClient = messageQueueClient; var loggerFactory = ObjectProviderFactory.GetService <ILoggerFactory>(); MessageProcessor = new MailboxProcessor(new DefaultProcessingMessageScheduler(), new OptionsWrapper <MailboxOption>(new MailboxOption { BatchCount = ConsumerConfig.MailboxProcessBatchCount }), loggerFactory.CreateLogger <MailboxProcessor>()); Logger = loggerFactory.CreateLogger(GetType().Name); }
public Mediator(IHandlerProvider handlerProvider) { this._handlerProvider = handlerProvider; }
public CommandConsumerBase(IHandlerProvider handlerProvider) { _handlerProvider = handlerProvider; _logger = IoCFactory.Resolve<ILoggerFactory>().Create(this.GetType()); }
public Bus(IHandlerProvider handlerProvider, IMessageDecoratorProvider decoratorProvider) { _handlerProvider = handlerProvider; _decoratorProvider = decoratorProvider; }
public CommandToHandlerMapper(IHandlerProvider handlerProvider) { _handlerProvider = handlerProvider; }
public void AddProvider(string name, IHandlerProvider provider) { this.providers.Add(name, provider.SetDependencyProvider(_provider)); }
public static async Task <T> HandleAsync <T>(this IHandlerProvider handlerProvider, IResolverSession session, string scopeId, string actionId, params object[] requests) { //var actionBytes = Encoding.UTF8.GetBytes(actionId); return(await HandleAsync <T>(handlerProvider, session, scopeId, actionId, requests, CancellationToken.None)); }