Interface IConfluentProducerWrapper
- Namespace
- Silverback.Messaging.Broker.Kafka
- Assembly
- Silverback.Integration.Kafka.dll
Wraps the underlying Confluent.Kafka.IProducer<TKey, TValue> and handles the connection lifecycle.
public interface IConfluentProducerWrapper : IBrokerClient, IDisposable, IAsyncDisposable
- Inherited Members
Properties
Configuration
Gets the producer configuration.
KafkaProducerConfiguration Configuration { get; }
Property Value
Producer
Gets or sets the related producer instance.
KafkaProducer Producer { get; set; }
Property Value
Methods
AbortTransaction()
Aborts the pending transaction.
void AbortTransaction()
BeginTransaction()
Begins a new transaction.
void BeginTransaction()
CommitTransaction()
Commits the pending transaction.
void CommitTransaction()
InitTransactions()
Initialize the transactions.
This function ensures any transactions initiated by previous instances of the producer with the same TransactionalId are completed. If the previous instance failed with a transaction in progress the previous transaction will be aborted.
This function needs to be called before any other transactional or produce functions are called when the TransactionalId is configured.
void InitTransactions()
Produce(TopicPartition, Message<byte[]?, byte[]?>, Action<DeliveryReport<byte[]?, byte[]?>>)
Produces the specified message to the specified topic and partition.
void Produce(TopicPartition topicPartition, Message<byte[]?, byte[]?> message, Action<DeliveryReport<byte[]?, byte[]?>> deliveryHandler)
Parameters
topicPartitionTopicPartitionThe target topic and partition.
messageMessage<byte[], byte[]>The message.
deliveryHandlerAction<DeliveryReport<byte[], byte[]>>The Confluent.Kafka.DeliveryReport<TKey, TValue> handler.
ProduceAsync(TopicPartition, Message<byte[]?, byte[]?>, CancellationToken)
Produces the specified message to the specified topic and partition.
Task<DeliveryResult<byte[]?, byte[]?>> ProduceAsync(TopicPartition topicPartition, Message<byte[]?, byte[]?> message, CancellationToken cancellationToken)
Parameters
topicPartitionTopicPartitionThe target topic and partition.
messageMessage<byte[], byte[]>The message.
cancellationTokenCancellationTokenThe cancellation token that can be used to cancel the operation.
Returns
- Task<DeliveryResult<byte[], byte[]>>
A Task<TResult> representing the asynchronous operation. The task result contains the Confluent.Kafka.DeliveryResult<TKey, TValue>.
SendOffsetsToTransaction(IReadOnlyCollection<TopicPartitionOffset>, IConsumerGroupMetadata)
Sends the consumed offsets to the transaction.
void SendOffsetsToTransaction(IReadOnlyCollection<TopicPartitionOffset> offsets, IConsumerGroupMetadata groupMetadata)
Parameters
offsetsIReadOnlyCollection<TopicPartitionOffset>The offsets to send.
groupMetadataIConsumerGroupMetadataThe consumer group metadata.