Class KafkaTransactionalProducer
- Namespace
- Silverback.Messaging.Broker
- Assembly
- Silverback.Integration.Kafka.dll
Produces the messages to an endpoint.
public sealed class KafkaTransactionalProducer : IProducer
- Inheritance
-
KafkaTransactionalProducer
- Implements
- Inherited Members
Constructors
KafkaTransactionalProducer(string, KafkaProducerConfiguration, IKafkaTransactionalProducerCollection)
Initializes a new instance of the KafkaTransactionalProducer class.
public KafkaTransactionalProducer(string name, KafkaProducerConfiguration configuration, IKafkaTransactionalProducerCollection transactionalProducers)
Parameters
namestringThe producer identifier.
configurationKafkaProducerConfigurationThe configuration containing only the actual endpoint.
transactionalProducersIKafkaTransactionalProducerCollection
Properties
Configuration
Gets the producer configuration.
public KafkaProducerConfiguration Configuration { get; }
Property Value
DisplayName
Gets the name to be displayed in the human-targeted output (e.g. logs, health checks result, etc.).
public string DisplayName { get; }
Property Value
EndpointConfiguration
Gets the endpoint configuration.
public ProducerEndpointConfiguration EndpointConfiguration { get; }
Property Value
Name
Gets the producer name.
public string Name { get; }
Property Value
Methods
Produce(IOutboundEnvelope)
Publishes the specified message.
public IBrokerMessageIdentifier? Produce(IOutboundEnvelope envelope)
Parameters
envelopeIOutboundEnvelopeThe envelope containing the message to be produced.
Returns
- IBrokerMessageIdentifier
The IBrokerMessageIdentifier of the produced record.
Produce(IOutboundEnvelope, Action<IBrokerMessageIdentifier?>, Action<Exception>)
Publishes the specified message.
public void Produce(IOutboundEnvelope envelope, Action<IBrokerMessageIdentifier?> onSuccess, Action<Exception> onError)
Parameters
envelopeIOutboundEnvelopeThe envelope containing the message to be produced.
onSuccessAction<IBrokerMessageIdentifier>The callback to be invoked when the message is successfully produced.
onErrorAction<Exception>The callback to be invoked when the produce fails.
Remarks
In this implementation the message is synchronously enqueued but produced asynchronously. The callbacks are called when the message is actually produced (or the produce failed).
Produce(object?, IReadOnlyCollection<MessageHeader>?)
Publishes the specified message.
public IBrokerMessageIdentifier Produce(object? message, IReadOnlyCollection<MessageHeader>? headers = null)
Parameters
messageobjectThe message.
headersIReadOnlyCollection<MessageHeader>The optional message headers.
Returns
- IBrokerMessageIdentifier
The IBrokerMessageIdentifier of the produced record.
Produce(object?, IReadOnlyCollection<MessageHeader>?, Action<IBrokerMessageIdentifier?>, Action<Exception>)
Publishes the specified message.
public void Produce(object? message, IReadOnlyCollection<MessageHeader>? headers, Action<IBrokerMessageIdentifier?> onSuccess, Action<Exception> onError)
Parameters
messageobjectThe message.
headersIReadOnlyCollection<MessageHeader>The optional message headers.
onSuccessAction<IBrokerMessageIdentifier>The callback to be invoked when the message is successfully produced.
onErrorAction<Exception>The callback to be invoked when the produce fails.
Remarks
In this implementation the message is synchronously enqueued but produced asynchronously. The callbacks are called when the message is actually produced (or the produce failed).
ProduceAsync(IOutboundEnvelope, CancellationToken)
Publishes the specified message.
public ValueTask<IBrokerMessageIdentifier?> ProduceAsync(IOutboundEnvelope envelope, CancellationToken cancellationToken = default)
Parameters
envelopeIOutboundEnvelopeThe envelope containing the message to be produced.
cancellationTokenCancellationTokenThe cancellation token that can be used to cancel the operation.
Returns
- ValueTask<IBrokerMessageIdentifier>
A ValueTask<TResult> representing the asynchronous operation. The ValueTask result contains the IBrokerMessageIdentifier of the produced record.
ProduceAsync(object?, IReadOnlyCollection<MessageHeader>?, CancellationToken)
Publishes the specified message.
public ValueTask<IBrokerMessageIdentifier?> ProduceAsync(object? message, IReadOnlyCollection<MessageHeader>? headers = null, CancellationToken cancellationToken = default)
Parameters
messageobjectThe message.
headersIReadOnlyCollection<MessageHeader>The optional message headers.
cancellationTokenCancellationTokenThe cancellation token that can be used to cancel the operation.
Returns
- ValueTask<IBrokerMessageIdentifier>
A ValueTask<TResult> representing the asynchronous operation. The ValueTask result contains the IBrokerMessageIdentifier of the produced record.
Produce<TState>(IOutboundEnvelope, Action<IBrokerMessageIdentifier?, TState>, Action<Exception, TState>, TState)
Publishes the specified message.
public void Produce<TState>(IOutboundEnvelope envelope, Action<IBrokerMessageIdentifier?, TState> onSuccess, Action<Exception, TState> onError, TState state)
Parameters
envelopeIOutboundEnvelopeThe envelope containing the message to be produced.
onSuccessAction<IBrokerMessageIdentifier, TState>The callback to be invoked when the message is successfully produced.
onErrorAction<Exception, TState>The callback to be invoked when the produce fails.
stateTStateThe state object to be passed to the callbacks.
Type Parameters
TStateThe type of the state object to be passed to the callbacks.
Remarks
In this implementation the message is synchronously enqueued but produced asynchronously. The callbacks are called when the message is actually produced (or the produce failed).
Produce<TState>(object?, IReadOnlyCollection<MessageHeader>?, Action<IBrokerMessageIdentifier?, TState>, Action<Exception, TState>, TState)
Publishes the specified message.
public void Produce<TState>(object? message, IReadOnlyCollection<MessageHeader>? headers, Action<IBrokerMessageIdentifier?, TState> onSuccess, Action<Exception, TState> onError, TState state)
Parameters
messageobjectThe message.
headersIReadOnlyCollection<MessageHeader>The optional message headers.
onSuccessAction<IBrokerMessageIdentifier, TState>The callback to be invoked when the message is successfully produced.
onErrorAction<Exception, TState>The callback to be invoked when the produce fails.
stateTStateThe state object to be passed to the callbacks.
Type Parameters
TStateThe type of the state object to be passed to the callbacks.
Remarks
In this implementation the message is synchronously enqueued but produced asynchronously. The callbacks are called when the message is actually produced (or the produce failed).
RawProduce(byte[]?, IReadOnlyCollection<MessageHeader>?)
Publishes the specified message as-is, without sending it through the behaviors pipeline.
public IBrokerMessageIdentifier RawProduce(byte[]? messageContent, IReadOnlyCollection<MessageHeader>? headers = null)
Parameters
messageContentbyte[]The message.
headersIReadOnlyCollection<MessageHeader>The optional message headers.
Returns
- IBrokerMessageIdentifier
The IBrokerMessageIdentifier of the produced record.
RawProduce(byte[]?, IReadOnlyCollection<MessageHeader>?, Action<IBrokerMessageIdentifier?>, Action<Exception>)
Publishes the specified message as-is, without sending it through the behaviors pipeline.
public void RawProduce(byte[]? messageContent, IReadOnlyCollection<MessageHeader>? headers, Action<IBrokerMessageIdentifier?> onSuccess, Action<Exception> onError)
Parameters
messageContentbyte[]The message.
headersIReadOnlyCollection<MessageHeader>The optional message headers.
onSuccessAction<IBrokerMessageIdentifier>The callback to be invoked when the message is successfully produced.
onErrorAction<Exception>The callback to be invoked when the produce fails.
Remarks
In this implementation the message is synchronously enqueued but produced asynchronously. The callbacks are called when the message is actually produced (or the produce failed).
RawProduce(Stream?, IReadOnlyCollection<MessageHeader>?)
Publishes the specified message as-is, without sending it through the behaviors pipeline.
public IBrokerMessageIdentifier RawProduce(Stream? messageStream, IReadOnlyCollection<MessageHeader>? headers = null)
Parameters
messageStreamStreamThe message.
headersIReadOnlyCollection<MessageHeader>The optional message headers.
Returns
- IBrokerMessageIdentifier
The IBrokerMessageIdentifier of the produced record.
RawProduce(Stream?, IReadOnlyCollection<MessageHeader>?, Action<IBrokerMessageIdentifier?>, Action<Exception>)
Publishes the specified message as-is, without sending it through the behaviors pipeline.
public void RawProduce(Stream? messageStream, IReadOnlyCollection<MessageHeader>? headers, Action<IBrokerMessageIdentifier?> onSuccess, Action<Exception> onError)
Parameters
messageStreamStreamThe message.
headersIReadOnlyCollection<MessageHeader>The optional message headers.
onSuccessAction<IBrokerMessageIdentifier>The callback to be invoked when the message is successfully produced.
onErrorAction<Exception>The callback to be invoked when the produce fails.
Remarks
In this implementation the message is synchronously enqueued but produced asynchronously. The callbacks are called when the message is actually produced (or the produce failed).
RawProduceAsync(byte[]?, IReadOnlyCollection<MessageHeader>?, CancellationToken)
Publishes the specified message as-is, without sending it through the behaviors pipeline.
public ValueTask<IBrokerMessageIdentifier?> RawProduceAsync(byte[]? messageContent, IReadOnlyCollection<MessageHeader>? headers = null, CancellationToken cancellationToken = default)
Parameters
messageContentbyte[]The message.
headersIReadOnlyCollection<MessageHeader>The optional message headers.
cancellationTokenCancellationTokenThe cancellation token that can be used to cancel the operation.
Returns
- ValueTask<IBrokerMessageIdentifier>
A ValueTask<TResult> representing the asynchronous operation. The ValueTask result contains the IBrokerMessageIdentifier of the produced record.
RawProduceAsync(Stream?, IReadOnlyCollection<MessageHeader>?, CancellationToken)
Publishes the specified message as-is, without sending it through the behaviors pipeline.
public ValueTask<IBrokerMessageIdentifier?> RawProduceAsync(Stream? messageStream, IReadOnlyCollection<MessageHeader>? headers = null, CancellationToken cancellationToken = default)
Parameters
messageStreamStreamThe message.
headersIReadOnlyCollection<MessageHeader>The optional message headers.
cancellationTokenCancellationTokenThe cancellation token that can be used to cancel the operation.
Returns
- ValueTask<IBrokerMessageIdentifier>
A ValueTask<TResult> representing the asynchronous operation. The ValueTask result contains the IBrokerMessageIdentifier of the produced record.
RawProduce<TState>(byte[]?, IReadOnlyCollection<MessageHeader>?, Action<IBrokerMessageIdentifier?, TState>, Action<Exception, TState>, TState)
Publishes the specified message as-is, without sending it through the behaviors pipeline.
public void RawProduce<TState>(byte[]? messageContent, IReadOnlyCollection<MessageHeader>? headers, Action<IBrokerMessageIdentifier?, TState> onSuccess, Action<Exception, TState> onError, TState state)
Parameters
messageContentbyte[]The message.
headersIReadOnlyCollection<MessageHeader>The optional message headers.
onSuccessAction<IBrokerMessageIdentifier, TState>The callback to be invoked when the message is successfully produced.
onErrorAction<Exception, TState>The callback to be invoked when the produce fails.
stateTStateThe state object to be passed to the callbacks.
Type Parameters
TStateThe type of the state object to be passed to the callbacks.
Remarks
In this implementation the message is synchronously enqueued but produced asynchronously. The callbacks are called when the message is actually produced (or the produce failed).
RawProduce<TState>(Stream?, IReadOnlyCollection<MessageHeader>?, Action<IBrokerMessageIdentifier?, TState>, Action<Exception, TState>, TState)
Publishes the specified message as-is, without sending it through the behaviors pipeline.
public void RawProduce<TState>(Stream? messageStream, IReadOnlyCollection<MessageHeader>? headers, Action<IBrokerMessageIdentifier?, TState> onSuccess, Action<Exception, TState> onError, TState state)
Parameters
messageStreamStreamThe message.
headersIReadOnlyCollection<MessageHeader>The optional message headers.
onSuccessAction<IBrokerMessageIdentifier, TState>The callback to be invoked when the message is successfully produced.
onErrorAction<Exception, TState>The callback to be invoked when the produce fails.
stateTStateThe state object to be passed to the callbacks.
Type Parameters
TStateThe type of the state object to be passed to the callbacks.
Remarks
In this implementation the message is synchronously enqueued but produced asynchronously. The callbacks are called when the message is actually produced (or the produce failed).