Provides consumer services for NATS.
Initializes a new instance of NatsConsumerServices.
public Void NatsConsumerServices(logger, options)| Name | Type | Summary |
|---|---|---|
| logger | ILogger<NatsConsumerServices> | |
| options | IOptions<QueueConnectionOptions> |
Registers a callback to be invoked when a message is available on the queue, then returns while consumption continues in the background.
The onMessage callback is executed with the message body as a byte[]
and the message headers as a dictionary, then the message is Ack; If an error occurred the
onError callback is executed if provided, then the message is Nack and requeued only
if the onError callback returned true.
public Task ConsumeFanoutAsync(fanout, onMessage, onError, cancellationToken)| Name | Type | Summary |
|---|---|---|
| fanout | String | The name of the fanout. |
| onMessage | Action<Byte[], IDictionary> | The callback action to process the message. |
| onError | Func<Exception, Boolean> | An error callback action called when an error occurred while processing a message. |
| cancellationToken | CancellationToken | A cancellation token that stops the background consumer. |
Setup a callback to be invoked when a message is available on the queue.
If the message is successfully deserialized the onMessage callback is executed then the message is Ack; If an error occurred the onError callback is executed if provided, then the message is Nack and requeued only if the onError callback returned true.
public Task ConsumeFanoutAsync<T>(fanout, onMessage, onError, serializer, cancellationToken)| Name | Type | Summary |
|---|---|---|
| fanout | String | The name of the fanout. |
| onMessage | Action<T, IDictionary> | The callback action to process the message. |
| onError | Func<Exception, Boolean> | An error callback action called when an error occurred while processing a message. |
| serializer | IMessageSerializer | A service to serialize the message. |
| cancellationToken | CancellationToken | A cancellation token. |
Setup a callback to be invoked when a message is available on the queue.
The onMessage callback is executed with the message body as a byte[]
and the message headers as a dictionary, then the message is Ack; If an error occurred the
onError callback is executed if provided, then the message is Nack and requeued only
if the onError callback returned true.
public Task ConsumeWorkQueueAsync(queue, onMessage, onError, cancellationToken)| Name | Type | Summary |
|---|---|---|
| queue | String | The name of the queue. |
| onMessage | Action<Byte[], IDictionary> | The callback action to process the message. |
| onError | Func<Exception, Boolean> | An error callback action called when an error occurred while processing a message. |
| cancellationToken | CancellationToken | A cancellation token. |
Setup a callback to be invoked when a message is available on the queue.
If the message is successfully deserialized the onMessage callback is executed then the message is Ack; If an error occurred the onError callback is executed if provided, then the message is Nack and requeued only if the onError callback returned true.
public Task ConsumeWorkQueueAsync<T>(queue, onMessage, onError, serializer, cancellationToken)| Name | Type | Summary |
|---|---|---|
| queue | String | The name of the queue. |
| onMessage | Action<T, IDictionary> | The callback action to process the message. |
| onError | Func<Exception, Boolean> | An error callback action called when an error occurred while processing a message. |
| serializer | IMessageSerializer | A service to serialize the message. |
| cancellationToken | CancellationToken | A cancellation token. |