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
MessagesCount
Gets the total number of messages written into all the partitions of the topic.
int MessagesCount { get; }
Property Value
Name
Gets the topic name.
string Name { get; }
Property Value
Partitions
Gets the partitions in the topic.
IReadOnlyList<IInMemoryPartition> Partitions { get; }
Property Value
Methods
AbortTransaction(Guid)
Aborts the transaction.
void AbortTransaction(Guid transactionalUniqueId)
Parameters
transactionalUniqueIdGuidThe transactional unique identifier.
CommitTransaction(Guid)
Commits the transaction.
void CommitTransaction(Guid transactionalUniqueId)
Parameters
transactionalUniqueIdGuidThe 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
partitionPartitionThe 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
partitionPartitionThe 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
partitionintThe index of the partition to be written to.
messageMessage<byte[], byte[]>The message to be written.
transactionalUniqueIdGuidThe transactional unique identifier.
Returns
- Offset
The Confluent.Kafka.Offset at which the message was written.