public Task Initialize(TimeSpan timeout) { _consumer = new ConsumerBuilder <byte[], byte[]>(_options.ToConsumerProperties()) .SetErrorHandler((sender, errorEvent) => _logger.LogError( "Consume error reason: {reason}, code: {code}, is broker error: {errorType}", errorEvent.Reason, errorEvent.Code, errorEvent.IsBrokerError )) .Build(); var offsetMode = Offset.Stored; switch (_options.ConsumeMode) { case ConsumeMode.LastCommittedMessage: offsetMode = Offset.Stored; break; case ConsumeMode.StreamEnd: offsetMode = Offset.End; break; case ConsumeMode.StreamStart: offsetMode = Offset.Beginning; break; } _consumer.Assign(new TopicPartitionOffset(_queueProperties.Namespace, (int)_queueProperties.PartitionId, offsetMode)); return(Task.CompletedTask); }
public Task Initialize(TimeSpan timeout) { _consumer = new Consumer <byte[], byte[]>(_options.ToConsumerProperties()); var offsetMode = Offset.Stored; switch (_options.ConsumeMode) { case ConsumeMode.LastCommittedMessage: offsetMode = Offset.Stored; break; case ConsumeMode.StreamEnd: offsetMode = Offset.End; break; case ConsumeMode.StreamStart: offsetMode = Offset.Beginning; break; } _consumer.Assign(new TopicPartitionOffset(_queueProperties.Namespace, (int)_queueProperties.PartitionId, offsetMode)); return(Task.CompletedTask); }