Class AmazonCommandQueue
- Namespace
- Savvyio.Extensions.SimpleQueueService.Commands
- Assembly
- Savvyio.Extensions.SimpleQueueService.dll
Provides a default implementation of the AmazonQueue<TRequest> class tailored for messages holding an ICommand implementation.
public class AmazonCommandQueue : AmazonQueue<ICommand>, IConfigurable<AmazonMessageOptions>, IPointToPointChannel<ICommand>, ISender<ICommand>, IReceiver<ICommand>, IHealthCheckProvider<IAmazonSQS>
- Inheritance
-
AmazonCommandQueue
- Implements
-
IHealthCheckProvider<IAmazonSQS>
- Derived
- Inherited Members
Examples
AmazonCommandQueue sends and receives commands through Amazon SQS. Configure it with AmazonCommandQueueOptions and use it as IPointToPointChannel<ICommand>.
using System;
using Amazon;
using Amazon.Runtime;
using Savvyio.Commands;
using Savvyio.Extensions.SimpleQueueService.Commands;
using Savvyio.Messaging;
namespace ExampleApp;
public class SqsCommandQueueConfig
{
public static AmazonCommandQueueOptions CreateOptions() => new AmazonCommandQueueOptions { Credentials = new AnonymousAWSCredentials(), Endpoint = RegionEndpoint.EUWest1, SourceQueue = new Uri("https://sqs.eu-west-1.amazonaws.com/123456789012/commands") };
public static IPointToPointChannel<ICommand> AsChannel(AmazonCommandQueue q) => q;
}
Constructors
AmazonCommandQueue(IMarshaller, AmazonCommandQueueOptions)
Initializes a new instance of the AmazonCommandQueue class.
public AmazonCommandQueue(IMarshaller marshaller, AmazonCommandQueueOptions options)
Parameters
marshallerIMarshallerThe IMarshaller that is used when converting ICommand implementations to messages.
optionsAmazonCommandQueueOptionsThe AmazonCommandQueueOptions used to configure this instance.
Exceptions
- ArgumentNullException
marshallercannot be null - or -optionscannot be null.- ArgumentException
optionsare not in a valid state.
Methods
GetHealthCheckTarget()
Returns a new Amazon.SQS.IAmazonSQS client instance configured for health probing of the underlying Amazon SQS service.
public IAmazonSQS GetHealthCheckTarget()
Returns
- IAmazonSQS
An Amazon.SQS.IAmazonSQS client instance used to probe the health status of the queue service.
ReceiveAsync(Action<AsyncOptions>)
Receive one or more command(s) asynchronous using Point-to-Point Channel/P2P MEP.
public override IAsyncEnumerable<IMessage<ICommand>> ReceiveAsync(Action<AsyncOptions> setup = null)
Parameters
setupAction<AsyncOptions>The AsyncOptions which may be configured.
Returns
- IAsyncEnumerable<IMessage<ICommand>>
A task that represents the asynchronous operation. The task result contains a sequence of IMessage<T> whose generic type argument is ICommand.
SendAsync(IEnumerable<IMessage<ICommand>>, Action<AsyncOptions>)
Sends the specified messages whose generic type argument is ICommand asynchronous using Point-to-Point Channel/P2P MEP.
public override Task SendAsync(IEnumerable<IMessage<ICommand>> messages, Action<AsyncOptions> setup = null)
Parameters
messagesIEnumerable<IMessage<ICommand>>The ICommand enclosed messages to send.
setupAction<AsyncOptions>The AsyncOptions which may be configured.
Returns
- Task
A task that represents the asynchronous operation.
Exceptions
- ArgumentNullException
messagescannot be null.