private void TryRun() { if (TryEnter()) { _scheduler.ScheduleMailbox(this); } }
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); }
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); } }
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)); } }
private void RegisterForExecution() { _mailboxScheduler.ScheduleMailbox(this); }