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); }
private void Mailbox_OnMessageEmpty(Mailbox mailbox) { _mailboxProcessorCommands.Add(new CompleteMessageCommand(mailbox)); }
public CompleteMessageCommand(Mailbox mailbox) { Mailbox = mailbox; }