Beispiel #1
0
        async Task <bool> TryCheckpoint(IPendingConfirmation confirmation)
        {
            _cancellationTokenSource.Token.ThrowIfCancellationRequested();

            LogContext.Debug?.Log("Partition: {PartitionId} updating checkpoint with offset: {Offset}", confirmation.Partition.PartitionId,
                                  confirmation.Offset);

            try
            {
                await confirmation.Checkpoint(_cancellationTokenSource.Token).ConfigureAwait(false);

                return(true);
            }
            catch (Exception exception)
            {
                LogContext.Error?.Log(exception, "Partition: {PartitionId} checkpoint failed with offset: {Offset}", confirmation.Partition,
                                      confirmation.Offset);
                confirmation.Faulted(exception);
                return(false);
            }
        }
Beispiel #2
0
        bool TryCheckpoint(IPendingConfirmation confirmation)
        {
            var offset = confirmation.Offset + 1;

            LogContext.Debug?.Log("Partition: {PartitionId} updating checkpoint with offset: {Offset}", confirmation.Partition, offset);
            try
            {
                _consumer.Commit(new[] { new TopicPartitionOffset(confirmation.Partition, offset) });
                return(true);
            }
            catch (KafkaException exception)
            {
                LogContext.Error?.Log(exception, "Partition: {PartitionId} checkpoint failed with offset: {Offset}", confirmation.Partition, offset);

                if (exception.Error.IsLocalError)
                {
                    throw;
                }

                confirmation.Faulted(exception);
                return(false);
            }
        }
 public void Faulted(IPendingConfirmation pendingConfirmation)
 {
     _published.TryRemove(pendingConfirmation.PublishTag, out _);
 }
Beispiel #4
0
 public async Task Pending(IPendingConfirmation confirmation)
 {
     await _channel.Writer.WriteAsync(confirmation).ConfigureAwait(false);
 }