private void SetLastReceivedMessagePerTopicPartition( Message <string, TMessage> message) { var topicPartition = message.TopicPartition; if (!LastReceivedMessagePerTopicPartition.ContainsKey(topicPartition)) { LastReceivedMessagePerTopicPartition.Add(topicPartition, message); } else { var cachedMessage = LastReceivedMessagePerTopicPartition[topicPartition]; if (message.Offset.Value > cachedMessage.Offset.Value) { LastReceivedMessagePerTopicPartition[topicPartition] = message; } } }
private void ProcessQueue() { var retryCount = 0; var isProcessed = false; while (!isProcessed) { try { ++retryCount; if (ShouldSkipRetriedMessages(retryCount)) { LogSkippedMessages(); break; } isProcessed = TryProcess(MessagesQueue); if (isProcessed) { LogProcessedMessages(); } else { LogRetriedMessages(); BackOff(); } } catch (Exception ex) { LogException(ex); BackOff(); } } CommitLastReceivedMessagePerTopicPartition(); MessagesQueue.Clear(); LastReceivedMessagePerTopicPartition.Clear(); }