Ejemplo n.º 1
0
        private void FixOffsetOutOfRangeExceptionAsync(Fetch request)
        {
            _metadataQueries.GetTopicOffsetAsync(request.Topic)
            .ContinueWith(t =>
            {
                try
                {
                    var offsets = t.Result.FirstOrDefault(x => x.PartitionId == request.PartitionId);
                    if (offsets == null)
                    {
                        return;
                    }

                    if (offsets.Offsets.Min() > request.Offset)
                    {
                        SetOffsetPosition(new OffsetPosition(request.PartitionId, offsets.Offsets.Min()));
                    }

                    if (offsets.Offsets.Max() < request.Offset)
                    {
                        SetOffsetPosition(new OffsetPosition(request.PartitionId, offsets.Offsets.Max()));
                    }
                }
                catch (Exception ex)
                {
                    _options.Log.ErrorFormat("Failed to fix the offset out of range exception on topic:{0} partition:{1}.  Polling will continue.  Exception={2}",
                                             request.Topic, request.PartitionId, ex);
                }
            });
        }
Ejemplo n.º 2
0
 public Task <List <OffsetResponse> > GetTopicOffsetAsync(string topic, int maxOffsets = 2, int time = -1)
 {
     return(_metadataQueries.GetTopicOffsetAsync(topic, maxOffsets, time));
 }