Show / Hide Table of Contents

    Interface IInMemoryTopic

    A mocked topic where the messages are just stored in memory. Note that it isn't obviously possible to accurately replicate the message broker behavior and this implementation is just intended for testing purposes.

    Namespace: Silverback.Messaging.Broker.Kafka.Mocks
    Assembly: Silverback.Integration.Kafka.Testing.dll
    Syntax
    public interface IInMemoryTopic

    Properties

    | Improve this doc View source

    BootstrapServers

    Gets the bootstrap servers string used to identify the target broker.

    Declaration
    string BootstrapServers { get; }
    Property Value
    Type Description
    string
    | Improve this doc View source

    MessagesCount

    Gets the total number of messages written into all the partitions of the topic.

    Declaration
    int MessagesCount { get; }
    Property Value
    Type Description
    int
    | Improve this doc View source

    Name

    Gets the topic name.

    Declaration
    string Name { get; }
    Property Value
    Type Description
    string
    | Improve this doc View source

    Partitions

    Gets the partitions in the topic.

    Declaration
    IReadOnlyList<IInMemoryPartition> Partitions { get; }
    Property Value
    Type Description
    IReadOnlyList<IInMemoryPartition>

    Methods

    | Improve this doc View source

    AbortTransaction(Guid)

    Aborts the transaction.

    Declaration
    void AbortTransaction(Guid transactionalUniqueId)
    Parameters
    Type Name Description
    Guid transactionalUniqueId

    The transactional unique identifier.

    | Improve this doc View source

    Assign(IMockedConfluentConsumer, Partition)

    Assigns the specified partition to the consumer.

    Declaration
    void Assign(IMockedConfluentConsumer consumer, Partition partition)
    Parameters
    Type Name Description
    IMockedConfluentConsumer consumer

    The IMockedConfluentConsumer instance.

    Partition partition

    The partition.

    | Improve this doc View source

    Commit(string, IEnumerable<TopicPartitionOffset>)

    Commits the offsets of the specified consumer group.

    Declaration
    IReadOnlyCollection<TopicPartitionOffset> Commit(string groupId, IEnumerable<TopicPartitionOffset> partitionOffsets)
    Parameters
    Type Name Description
    string groupId

    The consumer group id.

    IEnumerable<TopicPartitionOffset> partitionOffsets

    The offsets to be committed.

    Returns
    Type Description
    IReadOnlyCollection<TopicPartitionOffset>

    The actual committed offsets.

    | Improve this doc View source

    CommitTransaction(Guid)

    Commits the transaction.

    Declaration
    void CommitTransaction(Guid transactionalUniqueId)
    Parameters
    Type Name Description
    Guid transactionalUniqueId

    The transactional unique identifier.

    | Improve this doc View source

    EnsurePartitionsAssigned(IMockedConfluentConsumer, TimeSpan, CancellationToken)

    Ensures that a partition assignment has been given to the specified consumer, otherwise triggers the assignment process.

    Declaration
    void EnsurePartitionsAssigned(IMockedConfluentConsumer consumer, TimeSpan assignmentDelay, CancellationToken cancellationToken)
    Parameters
    Type Name Description
    IMockedConfluentConsumer consumer

    The consumer.

    TimeSpan assignmentDelay

    The delay to be applied before assigning the partitions.

    CancellationToken cancellationToken

    A CancellationToken to observe while waiting for the task to complete.

    | Improve this doc View source

    GetAllMessages()

    Gets all messages written into all the partitions of the topic.

    Declaration
    IReadOnlyList<Message<byte[]?, byte[]?>> GetAllMessages()
    Returns
    Type Description
    IReadOnlyList<Message<byte[], byte[]>>

    The messages written into the topic.

    | Improve this doc View source

    GetCommittedOffset(Partition, string)

    Gets the latest committed Confluent.Kafka.Offset for the specified partition.

    Declaration
    Offset GetCommittedOffset(Partition partition, string groupId)
    Parameters
    Type Name Description
    Partition partition

    The partition.

    string groupId

    The consumer group id.

    Returns
    Type Description
    Offset

    The latest Confluent.Kafka.Offset.

    | Improve this doc View source

    GetCommittedOffsets(string)

    Gets the latest committed Confluent.Kafka.Offset for each partition.

    Declaration
    IReadOnlyCollection<TopicPartitionOffset> GetCommittedOffsets(string groupId)
    Parameters
    Type Name Description
    string groupId

    The consumer group id.

    Returns
    Type Description
    IReadOnlyCollection<TopicPartitionOffset>

    The collection containing the latest Confluent.Kafka.Offset for each partition.

    | Improve this doc View source

    GetCommittedOffsetsCount(string)

    Gets the number of committed offsets for the specified consumer group. This number is usually equal to the number of consumed messages.

    Declaration
    long GetCommittedOffsetsCount(string groupId)
    Parameters
    Type Name Description
    string groupId

    The consumer group id.

    Returns
    Type Description
    long

    The number of committed offsets.

    | Improve this doc View source

    GetFirstOffset(Partition)

    Gets the Confluent.Kafka.Offset of the first message in the specified partition.

    Declaration
    Offset GetFirstOffset(Partition partition)
    Parameters
    Type Name Description
    Partition partition

    The partition.

    Returns
    Type Description
    Offset

    The Confluent.Kafka.Offset of the first message in the partition.

    | Improve this doc View source

    GetLastOffset(Partition)

    Gets the Confluent.Kafka.Offset of the latest message written to the specified partition.

    Declaration
    Offset GetLastOffset(Partition partition)
    Parameters
    Type Name Description
    Partition partition

    The partition.

    Returns
    Type Description
    Offset

    The Confluent.Kafka.Offset of the latest message in the partition.

    | Improve this doc View source

    Push(int, Message<byte[]?, byte[]?>, Guid)

    Writes a message to the topic.

    Declaration
    Offset Push(int partition, Message<byte[]?, byte[]?> message, Guid transactionalUniqueId)
    Parameters
    Type Name Description
    int partition

    The index of the partition to be written to.

    Message<byte[], byte[]> message

    The message to be written.

    Guid transactionalUniqueId

    The transactional unique identifier.

    Returns
    Type Description
    Offset

    The Confluent.Kafka.Offset at which the message was written.

    | Improve this doc View source

    Rebalance()

    Simulates a rebalance and causes all assignments to be revoked and reassigned.

    Declaration
    void Rebalance()
    | Improve this doc View source

    Subscribe(IMockedConfluentConsumer)

    Subscribes the consumer to the topic.

    Declaration
    void Subscribe(IMockedConfluentConsumer consumer)
    Parameters
    Type Name Description
    IMockedConfluentConsumer consumer

    The IMockedConfluentConsumer instance.

    | Improve this doc View source

    Unsubscribe(IMockedConfluentConsumer)

    Unsubscribes the consumer from the topic.

    Declaration
    void Unsubscribe(IMockedConfluentConsumer consumer)
    Parameters
    Type Name Description
    IMockedConfluentConsumer consumer

    The IMockedConfluentConsumer instance.

    | Improve this doc View source

    WaitUntilAllMessagesAreConsumedAsync(CancellationToken)

    Returns a Task that completes when all messages routed to the consumers have been processed and committed.

    Declaration
    Task WaitUntilAllMessagesAreConsumedAsync(CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    CancellationToken cancellationToken

    A CancellationToken to observe while waiting for the task to complete.

    Returns
    Type Description
    Task

    A Task that completes when all messages have been processed.

    • Improve this doc
    • View source
    GitHub E-Mail
    ↑ Back to top © 2020 Sergio Aquilini