Class NatsCommandQueue
- Namespace
- Savvyio.Extensions.NATS.Commands
- Assembly
- Savvyio.Extensions.NATS.dll
Provides a NATS JetStream implementation of the IPointToPointChannel<TRequest> for command messages.
public class NatsCommandQueue : NatsMessage, IDisposable, IAsyncDisposable, IHealthCheckProvider<INatsConnection>, IPointToPointChannel<ICommand>, ISender<ICommand>, IReceiver<ICommand>
- Inheritance
-
NatsCommandQueue
- Implements
-
IHealthCheckProvider<INatsConnection>
- Derived
- Inherited Members
Constructors
NatsCommandQueue(IMarshaller, NatsCommandQueueOptions)
Initializes a new instance of the NatsCommandQueue class.
public NatsCommandQueue(IMarshaller marshaller, NatsCommandQueueOptions options)
Parameters
marshallerIMarshallerThe marshaller used for serializing and deserializing messages.
optionsNatsCommandQueueOptionsThe NatsCommandQueueOptions used to configure this instance.
Exceptions
- ArgumentNullException
marshallercannot be null - or -optionscannot be null.- ArgumentException
optionsare not in a valid state.
Methods
ReceiveAsync(Action<AsyncOptions>)
Receives command messages asynchronously from the configured NATS JetStream consumer.
public IAsyncEnumerable<IMessage<ICommand>> ReceiveAsync(Action<AsyncOptions> setup = null)
Parameters
setupAction<AsyncOptions>The AsyncOptions which may be configured.
Returns
- IAsyncEnumerable<IMessage<ICommand>>
An IAsyncEnumerable<T> that yields IMessage<T> instances as they are received.
SendAsync(IEnumerable<IMessage<ICommand>>, Action<AsyncOptions>)
Sends the specified command messages asynchronously to the configured NATS JetStream subject.
public Task SendAsync(IEnumerable<IMessage<ICommand>> messages, Action<AsyncOptions> setup = null)
Parameters
messagesIEnumerable<IMessage<ICommand>>The messages to send.
setupAction<AsyncOptions>The AsyncOptions which may be configured.
Returns
See Also
IPointToPointChannel<TRequest>