Interface IMockedConsumerGroup
- Namespace
- Silverback.Messaging.Broker.Kafka.Mocks
- Assembly
- Silverback.Integration.Kafka.Testing.dll
A mocked consumer group. Note that it isn't obviously possible to accurately replicate the message broker behavior, and this implementation is just intended for testing purposes.
public interface IMockedConsumerGroup
Properties
BootstrapServers
Gets the bootstrap servers string used to identify the target broker.
string BootstrapServers { get; }
Property Value
CommittedOffsets
Gets the latest committed Confluent.Kafka.Offset for each topic partition.
IReadOnlyCollection<TopicPartitionOffset> CommittedOffsets { get; }
Property Value
- IReadOnlyCollection<TopicPartitionOffset>
The collection containing the latest Confluent.Kafka.Offset for each topic partition.
GroupId
Gets the consumer group id.
string GroupId { get; }
Property Value
Methods
GetCommittedOffset(TopicPartition)
Gets the latest committed Confluent.Kafka.Offset for the specified topic partition.
TopicPartitionOffset? GetCommittedOffset(TopicPartition topicPartition)
Parameters
topicPartitionTopicPartitionThe topic partition.
Returns
- TopicPartitionOffset
The latest committed Confluent.Kafka.Offset for the topic partition, or
nullif no offset has been committed for this partition.
GetCommittedOffsetsCount(string)
Gets the total number of committed offsets. This number is usually equal to the number of consumed messages.
long GetCommittedOffsetsCount(string topic)
Parameters
topicstringThe topic.
Returns
- long
The number of committed offsets.
Rebalance()
Triggers a rebalance that will be asynchronously executed.
void Rebalance()
WaitUntilAllMessagesAreConsumedAsync(IReadOnlyCollection<string>, CancellationToken)
Returns a Task that completes when all messages routed to the consumers have been processed and committed.
ValueTask WaitUntilAllMessagesAreConsumedAsync(IReadOnlyCollection<string> topicNames, CancellationToken cancellationToken = default)
Parameters
topicNamesIReadOnlyCollection<string>The names of the topics to wait for. If not specified, all topics are considered.
cancellationTokenCancellationTokenA CancellationToken to observe while waiting for the task to complete.