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>(routingKey, _processingMessageScheduler, _processingMessageHandler, _logger)); }); mailbox.EnqueueMessage(processingMessage); } else { _processingMessageScheduler.ScheduleMessage(processingMessage); } }
private bool TryExecuteNextMessage(X currentCompletedMessage) { var sequenceMessage = currentCompletedMessage.Message as ISequenceMessage; if (sequenceMessage == null) { return(false); } X nextMessage; if (_waitingToRetryMessageDict.TryRemove(sequenceMessage.Version + 1, out nextMessage)) { _mailboxScheduler.ScheduleMessage(nextMessage); return(true); } return(false); }