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
BootstrapServers
Gets the bootstrap servers string used to identify the target broker.
Declaration
string BootstrapServers { get; }
Property Value
| Type | Description |
|---|---|
| string |
MessagesCount
Gets the total number of messages written into all the partitions of the topic.
Declaration
int MessagesCount { get; }
Property Value
| Type | Description |
|---|---|
| int |
Name
Gets the topic name.
Declaration
string Name { get; }
Property Value
| Type | Description |
|---|---|
| string |
Partitions
Gets the partitions in the topic.
Declaration
IReadOnlyList<IInMemoryPartition> Partitions { get; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyList<IInMemoryPartition> |
Methods
AbortTransaction(Guid)
Aborts the transaction.
Declaration
void AbortTransaction(Guid transactionalUniqueId)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | transactionalUniqueId | The transactional unique identifier. |
CommitTransaction(Guid)
Commits the transaction.
Declaration
void CommitTransaction(Guid transactionalUniqueId)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | transactionalUniqueId | The transactional unique identifier. |
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. |
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. |
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. |
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. |