Class KafkaProducer
Inheritance
System.Object
KafkaProducer
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Silverback.Messaging.Broker
Assembly: Silverback.Integration.Kafka.dll
Syntax
public class KafkaProducer : Producer<KafkaBroker, KafkaProducerEndpoint>, IProducer, IDisposable
Constructors
| Improve this doc View sourceKafkaProducer(KafkaBroker, KafkaProducerEndpoint, IBrokerBehaviorsProvider<IProducerBehavior>, IConfluentProducersCache, IServiceProvider, IOutboundLogger<KafkaProducer>)
Initializes a new instance of the KafkaProducer class.
Declaration
public KafkaProducer(KafkaBroker broker, KafkaProducerEndpoint endpoint, IBrokerBehaviorsProvider<IProducerBehavior> behaviorsProvider, IConfluentProducersCache producersCache, IServiceProvider serviceProvider, IOutboundLogger<KafkaProducer> logger)
Parameters
Type | Name | Description |
---|---|---|
KafkaBroker | broker | The IBroker that instantiated this producer. |
KafkaProducerEndpoint | endpoint | The endpoint to produce to. |
IBrokerBehaviorsProvider<IProducerBehavior> | behaviorsProvider | |
IConfluentProducersCache | producersCache | |
System.IServiceProvider | serviceProvider | The System.IServiceProvider to be used to resolve the required services. |
IOutboundLogger<KafkaProducer> | logger |
Methods
| Improve this doc View sourceDispose()
Declaration
public void Dispose()
Dispose(Boolean)
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | disposing | A value indicating whether the method has been called by the |
GetConfluentProducer()
Returns the cached Confluent.Kafka.IProducer<TKey, TValue> or creates a new one.
Declaration
protected IProducer<byte[], byte[]> GetConfluentProducer()
Returns
Type | Description |
---|---|
Confluent.Kafka.IProducer<System.Byte[], System.Byte[]> | The Confluent.Kafka.IProducer<TKey, TValue>. |
ProduceCore(Object, Byte[], IReadOnlyCollection<MessageHeader>, String)
Declaration
protected override IBrokerMessageIdentifier ProduceCore(object message, byte[] messageBytes, IReadOnlyCollection<MessageHeader> headers, string actualEndpointName)
Parameters
Type | Name | Description |
---|---|---|
System.Object | message | |
System.Byte[] | messageBytes | |
System.Collections.Generic.IReadOnlyCollection<MessageHeader> | headers | |
System.String | actualEndpointName |
Returns
Type | Description |
---|---|
IBrokerMessageIdentifier |
Overrides
| Improve this doc View sourceProduceCore(Object, Byte[], IReadOnlyCollection<MessageHeader>, String, Action<IBrokerMessageIdentifier>, Action<Exception>)
Declaration
protected override void ProduceCore(object message, byte[] messageBytes, IReadOnlyCollection<MessageHeader> headers, string actualEndpointName, Action<IBrokerMessageIdentifier> onSuccess, Action<Exception> onError)
Parameters
Type | Name | Description |
---|---|---|
System.Object | message | |
System.Byte[] | messageBytes | |
System.Collections.Generic.IReadOnlyCollection<MessageHeader> | headers | |
System.String | actualEndpointName | |
System.Action<IBrokerMessageIdentifier> | onSuccess | |
System.Action<System.Exception> | onError |
Overrides
| Improve this doc View sourceProduceCore(Object, Stream, IReadOnlyCollection<MessageHeader>, String)
Declaration
protected override IBrokerMessageIdentifier ProduceCore(object message, Stream messageStream, IReadOnlyCollection<MessageHeader> headers, string actualEndpointName)
Parameters
Type | Name | Description |
---|---|---|
System.Object | message | |
System.IO.Stream | messageStream | |
System.Collections.Generic.IReadOnlyCollection<MessageHeader> | headers | |
System.String | actualEndpointName |
Returns
Type | Description |
---|---|
IBrokerMessageIdentifier |
Overrides
| Improve this doc View sourceProduceCore(Object, Stream, IReadOnlyCollection<MessageHeader>, String, Action<IBrokerMessageIdentifier>, Action<Exception>)
Declaration
protected override void ProduceCore(object message, Stream messageStream, IReadOnlyCollection<MessageHeader> headers, string actualEndpointName, Action<IBrokerMessageIdentifier> onSuccess, Action<Exception> onError)
Parameters
Type | Name | Description |
---|---|---|
System.Object | message | |
System.IO.Stream | messageStream | |
System.Collections.Generic.IReadOnlyCollection<MessageHeader> | headers | |
System.String | actualEndpointName | |
System.Action<IBrokerMessageIdentifier> | onSuccess | |
System.Action<System.Exception> | onError |
Overrides
| Improve this doc View sourceProduceCoreAsync(Object, Byte[], IReadOnlyCollection<MessageHeader>, String)
Declaration
protected override async Task<IBrokerMessageIdentifier> ProduceCoreAsync(object message, byte[] messageBytes, IReadOnlyCollection<MessageHeader> headers, string actualEndpointName)
Parameters
Type | Name | Description |
---|---|---|
System.Object | message | |
System.Byte[] | messageBytes | |
System.Collections.Generic.IReadOnlyCollection<MessageHeader> | headers | |
System.String | actualEndpointName |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<IBrokerMessageIdentifier> |
Overrides
| Improve this doc View sourceProduceCoreAsync(Object, Byte[], IReadOnlyCollection<MessageHeader>, String, Action<IBrokerMessageIdentifier>, Action<Exception>)
Declaration
protected override Task ProduceCoreAsync(object message, byte[] messageBytes, IReadOnlyCollection<MessageHeader> headers, string actualEndpointName, Action<IBrokerMessageIdentifier> onSuccess, Action<Exception> onError)
Parameters
Type | Name | Description |
---|---|---|
System.Object | message | |
System.Byte[] | messageBytes | |
System.Collections.Generic.IReadOnlyCollection<MessageHeader> | headers | |
System.String | actualEndpointName | |
System.Action<IBrokerMessageIdentifier> | onSuccess | |
System.Action<System.Exception> | onError |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
Overrides
| Improve this doc View sourceProduceCoreAsync(Object, Stream, IReadOnlyCollection<MessageHeader>, String)
Declaration
protected override async Task<IBrokerMessageIdentifier> ProduceCoreAsync(object message, Stream messageStream, IReadOnlyCollection<MessageHeader> headers, string actualEndpointName)
Parameters
Type | Name | Description |
---|---|---|
System.Object | message | |
System.IO.Stream | messageStream | |
System.Collections.Generic.IReadOnlyCollection<MessageHeader> | headers | |
System.String | actualEndpointName |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<IBrokerMessageIdentifier> |
Overrides
| Improve this doc View sourceProduceCoreAsync(Object, Stream, IReadOnlyCollection<MessageHeader>, String, Action<IBrokerMessageIdentifier>, Action<Exception>)
Declaration
protected override async Task ProduceCoreAsync(object message, Stream messageStream, IReadOnlyCollection<MessageHeader> headers, string actualEndpointName, Action<IBrokerMessageIdentifier> onSuccess, Action<Exception> onError)
Parameters
Type | Name | Description |
---|---|---|
System.Object | message | |
System.IO.Stream | messageStream | |
System.Collections.Generic.IReadOnlyCollection<MessageHeader> | headers | |
System.String | actualEndpointName | |
System.Action<IBrokerMessageIdentifier> | onSuccess | |
System.Action<System.Exception> | onError |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
Overrides
Implements
System.IDisposable