Exemplo n.º 1
0
 private void TryRun()
 {
     if (TryEnter())
     {
         _scheduler.ScheduleMailbox(this);
     }
 }
Exemplo n.º 2
0
        private void ExecuteProcessCommand(ProcessMessageCommand command)
        {
            var key = command.Message.Key;

            if (string.IsNullOrWhiteSpace(key))
            {
                throw new ArgumentException("Value cannot be null or whitespace.", nameof(key));
            }
            var mailbox = _mailboxDictionary.GetOrAdd(key, x =>
            {
                var box             = new Mailbox(key, _scheduler, _batchCount);
                box.OnMessageEmpty += Mailbox_OnMessageEmpty;
                return(box);
            });

            mailbox.EnqueueMessage(command.Message);
            _scheduler.ScheduleMailbox(mailbox);
        }
Exemplo n.º 3
0
        public void Process(X processingMessage)
        {
            var routingKey = processingMessage.Message.GetRoutingKey();

            if (!string.IsNullOrWhiteSpace(routingKey))
            {
                var mailbox = _mailboxDict.GetOrAdd(routingKey, x =>
                {
                    return(new ProcessingMessageMailbox <X, Y, Z>(_processingMessageScheduler, _processingMessageHandler));
                });
                mailbox.EnqueueMessage(processingMessage);
                _processingMessageScheduler.ScheduleMailbox(mailbox);
            }
            else
            {
                _processingMessageScheduler.ScheduleMessage(processingMessage);
            }
        }
Exemplo n.º 4
0
        private void ExecuteProcessCommand(ProcessMessageCommand <IMessageContext> command)
        {
            var messageContext        = command.Message;
            var processingMessageFunc = command.ProcessingMessageFunc;
            var key = messageContext.Key;

            if (!string.IsNullOrWhiteSpace(key))
            {
                var mailbox = _mailboxDict.GetOrAdd(key, x =>
                {
                    return(new ProcessingMailbox <IMessageContext>(key, _processingMessageScheduler, processingMessageFunc, HandleMailboxEmpty));
                });
                mailbox.EnqueueMessage(messageContext);
                _processingMessageScheduler.ScheduleMailbox(mailbox);
            }
            else
            {
                _processingMessageScheduler.SchedulProcessing(() => processingMessageFunc(messageContext));
            }
        }
Exemplo n.º 5
0
 private void RegisterForExecution()
 {
     _mailboxScheduler.ScheduleMailbox(this);
 }