Ejemplo n.º 1
0
 public KafkaOffset(Confluent.Kafka.TopicPartitionOffset topicPartitionOffset)
     : this(topicPartitionOffset.Topic, topicPartitionOffset.Partition.Value, topicPartitionOffset.Offset.Value)
 {
 }
Ejemplo n.º 2
0
        private async Task TryHandleMessage(Confluent.Kafka.Message <byte[], byte[]> message, Confluent.Kafka.TopicPartitionOffset tpo)
        {
            try
            {
                _messagesSinceCommit++;

                await HandleMessage(
                    message.Value,
                    message.Headers?.Select(h => h.ToSilverbackHeader()).ToList(),
                    new KafkaOffset(tpo));
            }
            catch (Exception ex)
            {
                _logger.LogCritical(ex,
                                    "Fatal error occurred consuming the message: {topic} {partition} @{offset}. " +
                                    "The consumer will be stopped.",
                                    tpo.Topic, tpo.Partition, tpo.Offset);

                Disconnect();
            }
        }
Ejemplo n.º 3
0
 public void Seek(Confluent.Kafka.TopicPartitionOffset tpo) => _innerConsumer.Seek(tpo);
Ejemplo n.º 4
0
        private async Task OnMessageReceived(Confluent.Kafka.Message <byte[], byte[]> message, Confluent.Kafka.TopicPartitionOffset tpo)
        {
            // Checking if the message was sent to the subscribed topic is necessary
            // when reusing the same consumer for multiple topics.
            if (!Endpoint.Names.Any(endpointName => tpo.Topic.Equals(endpointName, StringComparison.InvariantCultureIgnoreCase)))
            {
                return;
            }

            await TryHandleMessage(message, tpo);
        }