NatsCommandQueue<TMarker> Class
Definition
- Namespace
- Savvyio.Extensions.DependencyInjection.NATS.Commands
- Assemblies
- Savvyio.Extensions.DependencyInjection.NATS.dll
Provides a default implementation of the NatsMessage class for messages holding an ICommand implementation.
public class NatsCommandQueue<TMarker> : NatsCommandQueue, IDisposable, IAsyncDisposable, IHealthCheckProvider<INatsConnection>, IPointToPointChannel<ICommand, TMarker>, IPointToPointChannel<ICommand>, ISender<ICommand, TMarker>, ISender<ICommand>, IReceiver<ICommand, TMarker>, IReceiver<ICommand>, IDependencyInjectionMarker<TMarker>
Type Parameters
TMarker
- Inheritance
-
objectNatsCommandQueue<TMarker>
- Implements
-
IHealthCheckProvider<INatsConnection>IPointToPointChannel<ICommand, TMarker>IDependencyInjectionMarker<TMarker>
- Inherited Members
Examples
NatsCommandQueue<TMarker> is the DI-registered NATS command queue with a lifetime marker. Register it with AddNatsCommandQueue and resolve it as NatsCommandQueue or IPointToPointChannel<ICommand>.
using System;
using Microsoft.Extensions.DependencyInjection;
using Savvyio.Commands;
using Savvyio.Extensions.DependencyInjection;
using Savvyio.Extensions.DependencyInjection.NATS;
using Savvyio.Extensions.NATS.Commands;
using Savvyio.Messaging;
namespace ExampleApp;
public static class NatsQueueUsage
{
public static NatsCommandQueue GetQueue(IServiceProvider provider)
{
return provider.GetRequiredService<NatsCommandQueue>();
}
public static IPointToPointChannel<ICommand> GetChannel(IServiceProvider provider)
{
return provider.GetRequiredService<IPointToPointChannel<ICommand>>();
}
public static IServiceCollection Register(IServiceCollection services)
{
services.AddSavvyIO();
services.AddNatsCommandQueue(o => { o.Subject = "commands"; });
return services;
}
}
Constructors
| Name | Description |
|---|---|
| NatsCommandQueue(IMarshaller, NatsCommandQueueOptions<TMarker>) | Initializes a new instance of the NatsCommandQueue<TMarker> class. |
See Also
NatsCommandQueue<TMarker>
IPointToPointChannel<TRequest, TMarker>