Class RabbitProducer
Produces to an endpoint.
Inherited Members
Namespace: Silverback.Messaging.Broker
Assembly: Silverback.Integration.RabbitMQ.dll
Syntax
public sealed class RabbitProducer : Producer<RabbitBroker, RabbitProducerEndpoint>, IProducer, IDisposable
Constructors
| Improve this doc View sourceRabbitProducer(RabbitBroker, RabbitProducerEndpoint, IBrokerBehaviorsProvider<IProducerBehavior>, IServiceProvider, IOutboundLogger<Producer>)
Initializes a new instance of the RabbitProducer class.
Declaration
public RabbitProducer(RabbitBroker broker, RabbitProducerEndpoint endpoint, IBrokerBehaviorsProvider<IProducerBehavior> behaviorsProvider, IServiceProvider serviceProvider, IOutboundLogger<Producer> logger)
Parameters
Type | Name | Description |
---|---|---|
RabbitBroker | broker | The IBroker that instantiated this producer. |
RabbitProducerEndpoint | endpoint | The endpoint to produce to. |
IBrokerBehaviorsProvider<IProducerBehavior> | behaviorsProvider | |
IServiceProvider | serviceProvider | The IServiceProvider to be used to resolve the needed services. |
IOutboundLogger<Producer> | logger | The ISilverbackLogger. |
Methods
| Improve this doc View sourceDispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Declaration
public void Dispose()
ProduceCore(object?, byte[]?, IReadOnlyCollection<MessageHeader>?, string)
Publishes the specified message and returns its identifier.
Declaration
protected override IBrokerMessageIdentifier? ProduceCore(object? message, byte[]? messageBytes, IReadOnlyCollection<MessageHeader>? headers, string actualEndpointName)
Parameters
Type | Name | Description |
---|---|---|
object | message | The message to be delivered before serialization. This might be null if RawProduce(byte[]?, IReadOnlyCollection<MessageHeader>?), RawProduce(Stream?, IReadOnlyCollection<MessageHeader>?), RawProduceAsync(byte[]?, IReadOnlyCollection<MessageHeader>?) or RawProduceAsync(Stream?, IReadOnlyCollection<MessageHeader>?) have been used to produce. |
byte[] | messageBytes | The actual serialized message to be delivered. |
IReadOnlyCollection<MessageHeader> | headers | The message headers. |
string | actualEndpointName | The actual endpoint to produce to. |
Returns
Type | Description |
---|---|
IBrokerMessageIdentifier | The message identifier assigned by the broker (the Kafka offset or similar). |
Overrides
| Improve this doc View sourceProduceCore(object?, byte[]?, IReadOnlyCollection<MessageHeader>?, string, Action<IBrokerMessageIdentifier?>, Action<Exception>)
Publishes the specified message and returns its identifier.
Declaration
protected override void ProduceCore(object? message, byte[]? messageBytes, IReadOnlyCollection<MessageHeader>? headers, string actualEndpointName, Action<IBrokerMessageIdentifier?> onSuccess, Action<Exception> onError)
Parameters
Type | Name | Description |
---|---|---|
object | message | The message to be delivered before serialization. This might be null if RawProduce(byte[]?, IReadOnlyCollection<MessageHeader>?), RawProduce(Stream?, IReadOnlyCollection<MessageHeader>?), RawProduceAsync(byte[]?, IReadOnlyCollection<MessageHeader>?) or RawProduceAsync(Stream?, IReadOnlyCollection<MessageHeader>?) have been used to produce. |
byte[] | messageBytes | The actual serialized message to be delivered. |
IReadOnlyCollection<MessageHeader> | headers | The message headers. |
string | actualEndpointName | The actual endpoint to produce to. |
Action<IBrokerMessageIdentifier> | onSuccess | The callback to be invoked when the message is successfully produced. |
Action<Exception> | onError | The callback to be invoked when the produce fails. |
Overrides
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).
ProduceCore(object?, Stream?, IReadOnlyCollection<MessageHeader>?, string)
Publishes the specified message and returns its identifier.
Declaration
protected override IBrokerMessageIdentifier? ProduceCore(object? message, Stream? messageStream, IReadOnlyCollection<MessageHeader>? headers, string actualEndpointName)
Parameters
Type | Name | Description |
---|---|---|
object | message | The message to be delivered before serialization. This might be null if RawProduce(byte[]?, IReadOnlyCollection<MessageHeader>?), RawProduce(Stream?, IReadOnlyCollection<MessageHeader>?), RawProduceAsync(byte[]?, IReadOnlyCollection<MessageHeader>?) or RawProduceAsync(Stream?, IReadOnlyCollection<MessageHeader>?) have been used to produce. |
Stream | messageStream | The actual serialized message to be delivered. |
IReadOnlyCollection<MessageHeader> | headers | The message headers. |
string | actualEndpointName | The actual endpoint to produce to. |
Returns
Type | Description |
---|---|
IBrokerMessageIdentifier | The message identifier assigned by the broker (the Kafka offset or similar). |
Overrides
| Improve this doc View sourceProduceCore(object?, Stream?, IReadOnlyCollection<MessageHeader>?, string, Action<IBrokerMessageIdentifier?>, Action<Exception>)
Publishes the specified message and returns its identifier.
Declaration
protected override void ProduceCore(object? message, Stream? messageStream, IReadOnlyCollection<MessageHeader>? headers, string actualEndpointName, Action<IBrokerMessageIdentifier?> onSuccess, Action<Exception> onError)
Parameters
Type | Name | Description |
---|---|---|
object | message | The message to be delivered before serialization. This might be null if RawProduce(byte[]?, IReadOnlyCollection<MessageHeader>?), RawProduce(Stream?, IReadOnlyCollection<MessageHeader>?), RawProduceAsync(byte[]?, IReadOnlyCollection<MessageHeader>?) or RawProduceAsync(Stream?, IReadOnlyCollection<MessageHeader>?) have been used to produce. |
Stream | messageStream | The message to be delivered. |
IReadOnlyCollection<MessageHeader> | headers | The message headers. |
string | actualEndpointName | The actual endpoint to produce to. |
Action<IBrokerMessageIdentifier> | onSuccess | The callback to be invoked when the message is successfully produced. |
Action<Exception> | onError | The callback to be invoked when the produce fails. |
Overrides
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).
ProduceCoreAsync(object?, byte[]?, IReadOnlyCollection<MessageHeader>?, string)
Publishes the specified message and returns its identifier.
Declaration
protected override Task<IBrokerMessageIdentifier?> ProduceCoreAsync(object? message, byte[]? messageBytes, IReadOnlyCollection<MessageHeader>? headers, string actualEndpointName)
Parameters
Type | Name | Description |
---|---|---|
object | message | The message to be delivered before serialization. This might be null if RawProduce(byte[]?, IReadOnlyCollection<MessageHeader>?), RawProduce(Stream?, IReadOnlyCollection<MessageHeader>?), RawProduceAsync(byte[]?, IReadOnlyCollection<MessageHeader>?) or RawProduceAsync(Stream?, IReadOnlyCollection<MessageHeader>?) have been used to produce. |
byte[] | messageBytes | The actual serialized message to be delivered. |
IReadOnlyCollection<MessageHeader> | headers | The message headers. |
string | actualEndpointName | The actual endpoint to produce to. |
Returns
Type | Description |
---|---|
Task<IBrokerMessageIdentifier> | A Task<TResult> representing the asynchronous operation. The task result contains the message identifier assigned by the broker (the Kafka offset or similar). |
Overrides
| Improve this doc View sourceProduceCoreAsync(object?, byte[]?, IReadOnlyCollection<MessageHeader>?, string, Action<IBrokerMessageIdentifier?>, Action<Exception>)
Publishes the specified message and returns its identifier.
Declaration
protected override Task ProduceCoreAsync(object? message, byte[]? messageBytes, IReadOnlyCollection<MessageHeader>? headers, string actualEndpointName, Action<IBrokerMessageIdentifier?> onSuccess, Action<Exception> onError)
Parameters
Type | Name | Description |
---|---|---|
object | message | The message to be delivered before serialization. This might be null if RawProduce(byte[]?, IReadOnlyCollection<MessageHeader>?), RawProduce(Stream?, IReadOnlyCollection<MessageHeader>?), RawProduceAsync(byte[]?, IReadOnlyCollection<MessageHeader>?) or RawProduceAsync(Stream?, IReadOnlyCollection<MessageHeader>?) have been used to produce. |
byte[] | messageBytes | The actual serialized message to be delivered. |
IReadOnlyCollection<MessageHeader> | headers | The message headers. |
string | actualEndpointName | The actual endpoint to produce to. |
Action<IBrokerMessageIdentifier> | onSuccess | The callback to be invoked when the message is successfully produced. |
Action<Exception> | onError | The callback to be invoked when the produce fails. |
Returns
Type | Description |
---|---|
Task | A Task representing the asynchronous operation. The Task will complete as soon as the message is enqueued. |
Overrides
Remarks
The returned Task completes when the message is enqueued while the callbacks are called when the message is actually produced (or the produce failed).
ProduceCoreAsync(object?, Stream?, IReadOnlyCollection<MessageHeader>?, string)
Publishes the specified message and returns its identifier.
Declaration
protected override Task<IBrokerMessageIdentifier?> ProduceCoreAsync(object? message, Stream? messageStream, IReadOnlyCollection<MessageHeader>? headers, string actualEndpointName)
Parameters
Type | Name | Description |
---|---|---|
object | message | The message to be delivered before serialization. This might be null if RawProduce(byte[]?, IReadOnlyCollection<MessageHeader>?), RawProduce(Stream?, IReadOnlyCollection<MessageHeader>?), RawProduceAsync(byte[]?, IReadOnlyCollection<MessageHeader>?) or RawProduceAsync(Stream?, IReadOnlyCollection<MessageHeader>?) have been used to produce. |
Stream | messageStream | The message to be delivered. |
IReadOnlyCollection<MessageHeader> | headers | The message headers. |
string | actualEndpointName | The actual endpoint to produce to. |
Returns
Type | Description |
---|---|
Task<IBrokerMessageIdentifier> | A Task<TResult> representing the asynchronous operation. The task result contains the message identifier assigned by the broker (the Kafka offset or similar). |
Overrides
| Improve this doc View sourceProduceCoreAsync(object?, Stream?, IReadOnlyCollection<MessageHeader>?, string, Action<IBrokerMessageIdentifier?>, Action<Exception>)
Publishes the specified message and returns its identifier.
Declaration
protected override Task ProduceCoreAsync(object? message, Stream? messageStream, IReadOnlyCollection<MessageHeader>? headers, string actualEndpointName, Action<IBrokerMessageIdentifier?> onSuccess, Action<Exception> onError)
Parameters
Type | Name | Description |
---|---|---|
object | message | The message to be delivered before serialization. This might be null if RawProduce(byte[]?, IReadOnlyCollection<MessageHeader>?), RawProduce(Stream?, IReadOnlyCollection<MessageHeader>?), RawProduceAsync(byte[]?, IReadOnlyCollection<MessageHeader>?) or RawProduceAsync(Stream?, IReadOnlyCollection<MessageHeader>?) have been used to produce. |
Stream | messageStream | The message to be delivered. |
IReadOnlyCollection<MessageHeader> | headers | The message headers. |
string | actualEndpointName | The actual endpoint to produce to. |
Action<IBrokerMessageIdentifier> | onSuccess | The callback to be invoked when the message is successfully produced. |
Action<Exception> | onError | The callback to be invoked when the produce fails. |
Returns
Type | Description |
---|---|
Task | A Task representing the asynchronous operation. The Task will complete as soon as the message is enqueued. |
Overrides
Remarks
The returned Task completes when the message is enqueued while the callbacks are called when the message is actually produced (or the produce failed).