Exemplo n.º 1
0
 public PipeInvocation(IMessageHandlerInvoker invoker, IMessage message, MessageContext messageContext, IEnumerable<IPipe> pipes)
 {
     _invoker = invoker;
     _message = message;
     _messageContext = messageContext;
     _pipes = pipes.AsList();
 }
Exemplo n.º 2
0
        public void SetHandled(IMessageHandlerInvoker invoker, Exception error)
        {
            if (error != null)
                AddException(invoker.MessageHandlerType, error);

            if (Interlocked.Decrement(ref _remainingHandlerCount) == 0)
                _continuation(this, new DispatchResult(_exceptions));
        }
        public DefaultConfigurator MessageHandlerInvoker(IMessageHandlerInvoker messageHandlerInvoker)
        {
            Guard.AgainstNull(messageHandlerInvoker, "messageHandlerInvoker");

            _configuration.MessageHandlerInvoker = messageHandlerInvoker;

            return this;
        }
        public InMemoryMessageListener(
         Type messageHandlerType,
         IMessageHandlerTypesIndexFactory messageHandlerTypesIndexFactory,
         IMessageHandlerInvokerFactory messageHandlerInvokerFactory,
         IConfiguration configuration,
         IMessageServiceExchange messageServiceExchange)
        {
            this.configuration = configuration;
             this.messageServiceExchange = messageServiceExchange;

             var messageHandlerTypesIndex = messageHandlerTypesIndexFactory.Create(new[] { messageHandlerType });
             this.messageHandlerInvoker = messageHandlerInvokerFactory.CreateAggregate(messageHandlerTypesIndex);
             this.messageType = messageHandlerTypesIndex.GetAllMessageTypes().Single();
        }
		public ProcessMessageHandlerInvoker(IDatabaseContextFactory databaseContextFactory, IEventStore eventStore,
			IKeyStore keyStore,
			IProcessConfiguration configuration)
		{
			Guard.AgainstNull(databaseContextFactory, "databaseContextFactory");
			Guard.AgainstNull(eventStore, "eventStore");
			Guard.AgainstNull(eventStore, "keyStore");
			Guard.AgainstNull(configuration, "configuration");

			_databaseContextFactory = databaseContextFactory;
			_eventStore = eventStore;
			_keyStore = keyStore;
			_configuration = configuration;

			_defaultMessageHandlerInvoker = new DefaultMessageHandlerInvoker();
		}
        public void SetupBeforeEachTest()
        {
            this.messageHandlerTypesIndexFactory = A.Fake<IMessageHandlerTypesIndexFactory>();
             this.messageHandlerInvokerFactory = A.Fake<IMessageHandlerInvokerFactory>();
             this.messageHandlerTypesIndex = A.Fake<IMessageHandlerTypesIndex>();
             this.messageHandlerInvoker = A.Fake<IMessageHandlerInvoker>();
             this.configuration = A.Fake<IConfiguration>();
             this.messageServiceExchange = A.Fake<IMessageServiceExchange>();

             A.CallTo(() => this.messageHandlerTypesIndexFactory.Create(A<Type[]>._)).Returns(this.messageHandlerTypesIndex);
             A.CallTo(() => this.messageHandlerInvokerFactory.CreateAggregate(A<IMessageHandlerTypesIndex>._)).Returns(this.messageHandlerInvoker);

             var messageType = typeof(TestMessageA);
             A.CallTo(() => this.messageHandlerTypesIndex.GetAllMessageTypes()).Returns(new[] { messageType });

             this.componentUnderTest = new InMemoryMessageListener(typeof(object), this.messageHandlerTypesIndexFactory, this.messageHandlerInvokerFactory, this.configuration, this.messageServiceExchange);
        }
 public RabbitMQMessageListener(
  IChannelManagerFactory channelManagerFactory,
  Type[] messageHandlerTypes,
  IMessageHandlerTypesIndexFactory messageHandlerTypesIndexFactory,
  IMessageHandlerInvokerFactory messageHandlerInvokerFactory,
  IQueueNameConvention queueNameConvention,
  IMessageEncoder messageEncoder,
  IMessageSerialiser messageSerialiser,
  ILogger logger,
  IConfiguration configuration)
 {
     this.channelManager = channelManagerFactory.Create();
      this.queueNameConvention = queueNameConvention;
      this.messageEncoder = messageEncoder;
      this.messageSerialiser = messageSerialiser;
      this.logger = logger;
      this.configuration = configuration;
      this.messageHandlerTypesIndex = messageHandlerTypesIndexFactory.Create(messageHandlerTypes);
      this.messageHandlerInvoker = messageHandlerInvokerFactory.CreateAggregate(this.messageHandlerTypesIndex);
 }
        public void SetupBeforeEachTest()
        {
            this.channelManagerFactory = A.Fake<IChannelManagerFactory>();
             this.channelManager = A.Fake<IChannelManager>();
             this.queueNameConvention = A.Fake<IQueueNameConvention>();
             this.messageHandlerTypesIndexFactory = A.Fake<IMessageHandlerTypesIndexFactory>();
             this.messageHandlerInvokerFactory = A.Fake<IMessageHandlerInvokerFactory>();
             this.messageEncoder = A.Fake<IMessageEncoder>();
             this.messageSerialiser = A.Fake<IMessageSerialiser>();
             this.logger = A.Fake<ILogger>();
             this.configuration = A.Fake<IConfiguration>();
             this.model = A.Fake<IModel>();
             this.messageHandlerTypesIndex = A.Fake<IMessageHandlerTypesIndex>();
             this.messageHandlerInvoker = A.Fake<IMessageHandlerInvoker>();
             this.messageHandlerTypes = new Type[0];

             A.CallTo(() => this.channelManagerFactory.Create()).Returns(this.channelManager);
             A.CallTo(() => this.channelManager.CreateChannel()).Returns(this.model);
             A.CallTo(() => this.messageHandlerTypesIndexFactory.Create(A<Type[]>._)).Returns(this.messageHandlerTypesIndex);
             A.CallTo(() => this.messageHandlerInvokerFactory.CreateAggregate(A<IMessageHandlerTypesIndex>._)).Returns(this.messageHandlerInvoker);
             A.CallTo(() => this.configuration.ListenTimeout).Returns(20);

             this.componentUnderTest = new RabbitMQMessageListener(this.channelManagerFactory, this.messageHandlerTypes, this.messageHandlerTypesIndexFactory, this.messageHandlerInvokerFactory, this.queueNameConvention, this.messageEncoder, this.messageSerialiser, this.logger, this.configuration);
        }
Exemplo n.º 9
0
        private void Dispatch(MessageDispatch dispatch, IMessageHandlerInvoker invoker)
        {
            var context = dispatch.Context.WithDispatchQueueName(invoker.DispatchQueueName);
            var invocation = _pipeManager.BuildPipeInvocation(invoker, dispatch.Message, context);

            var isInSameDispatchQueue = ShouldRunInCurrentDispatchQueue(invoker.DispatchQueueName, dispatch.Context.DispatchQueueName);

            if (invoker.CanInvokeSynchronously && (dispatch.ShouldRunSynchronously || isInSameDispatchQueue))
                DispatchSync(invocation, dispatch);
            else
                DispatchAsync(invocation, dispatch);
        }
Exemplo n.º 10
0
        public void RemoveInvoker(IMessageHandlerInvoker eventHandlerInvoker)
        {
            lock (_invokers)
            {
                var messageTypeInvokers = _invokers.GetValueOrDefault(eventHandlerInvoker.MessageTypeId);
                if (messageTypeInvokers == null)
                    return;

                var newMessageTypeInvokers = new List<IMessageHandlerInvoker>(messageTypeInvokers.Where(x => x != eventHandlerInvoker));
                _invokers[eventHandlerInvoker.MessageTypeId] = newMessageTypeInvokers;
            }
        }
Exemplo n.º 11
0
        public void AddInvoker(IMessageHandlerInvoker eventHandlerInvoker)
        {
            lock (_invokers)
            {
                var messageTypeInvokers = _invokers.GetValueOrDefault(eventHandlerInvoker.MessageTypeId) ?? new List<IMessageHandlerInvoker>();
                var newMessageTypeInvokers = new List<IMessageHandlerInvoker>(messageTypeInvokers.Count + 1);
                newMessageTypeInvokers.AddRange(messageTypeInvokers);
                newMessageTypeInvokers.AddRange(eventHandlerInvoker);

                _invokers[eventHandlerInvoker.MessageTypeId] = newMessageTypeInvokers;
            }
            
        }
Exemplo n.º 12
0
 public PipeInvocation BuildPipeInvocation(IMessageHandlerInvoker messageHandlerInvoker, IMessage message, MessageContext messageContext)
 {
     var pipes = GetEnabledPipes(messageHandlerInvoker.MessageHandlerType);
     return new PipeInvocation(messageHandlerInvoker, message, messageContext, pipes);
 }
Exemplo n.º 13
0
 public void AddInvoker(IMessageHandlerInvoker eventHandlerInvoker)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 14
0
        public void AddInvoker(IMessageHandlerInvoker eventHandlerInvoker)
        {
            var messageTypeInvokers = _invokers.GetOrAdd(eventHandlerInvoker.MessageTypeId, x => new ConcurrentList <IMessageHandlerInvoker>());

            messageTypeInvokers.Add(eventHandlerInvoker);
        }
Exemplo n.º 15
0
 public override bool CanMergeWith(IMessageHandlerInvoker other)
 {
     return(other is BatchedMessageHandlerInvoker otherBatchedInvoker &&
            otherBatchedInvoker.MessageHandlerType == MessageHandlerType &&
            otherBatchedInvoker.MessageType == MessageType);
 }
Exemplo n.º 16
0
        public PipeInvocation BuildPipeInvocation(IMessageHandlerInvoker messageHandlerInvoker, List <IMessage> messages, MessageContext messageContext)
        {
            var pipes = GetEnabledPipes(messageHandlerInvoker.MessageHandlerType);

            return(new PipeInvocation(messageHandlerInvoker, messages, messageContext, pipes));
        }