Table of Contents

Interface IInMemoryTopic

Namespace
Silverback.Messaging.Broker.Kafka.Mocks
Assembly
Silverback.Integration.Kafka.Testing.dll

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.

public interface IInMemoryTopic

Properties

BootstrapServers

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

string BootstrapServers { get; }

Property Value

string

MessagesCount

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

int MessagesCount { get; }

Property Value

int

Name

Gets the topic name.

string Name { get; }

Property Value

string

Partitions

Gets the partitions in the topic.

IReadOnlyList<IInMemoryPartition> Partitions { get; }

Property Value

IReadOnlyList<IInMemoryPartition>

Methods

AbortTransaction(Guid)

Aborts the transaction.

void AbortTransaction(Guid transactionalUniqueId)

Parameters

transactionalUniqueId Guid

The transactional unique identifier.

CommitTransaction(Guid)

Commits the transaction.

void CommitTransaction(Guid transactionalUniqueId)

Parameters

transactionalUniqueId Guid

The transactional unique identifier.

GetAllMessages()

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

IReadOnlyList<Message<byte[]?, byte[]?>> GetAllMessages()

Returns

IReadOnlyList<Message<byte[], byte[]>>

The messages written into the topic.

GetFirstOffset(Partition)

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

Offset GetFirstOffset(Partition partition)

Parameters

partition Partition

The partition.

Returns

Offset

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

GetLastOffset(Partition)

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

Offset GetLastOffset(Partition partition)

Parameters

partition Partition

The partition.

Returns

Offset

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

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

Writes a message to the topic.

Offset Push(int partition, Message<byte[]?, byte[]?> message, Guid transactionalUniqueId)

Parameters

partition int

The index of the partition to be written to.

message Message<byte[], byte[]>

The message to be written.

transactionalUniqueId Guid

The transactional unique identifier.

Returns

Offset

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