Table of Contents

Class DefaultMessageManager

Namespace
AWS.Messaging.Services
Assembly
AWS.Messaging.dll

Instances of IMessageManager manage the lifecycle of a message being processed.

public class DefaultMessageManager : IMessageManager
Inheritance
DefaultMessageManager
Implements

Remarks

Responsibilities:

  • Start the async work of processing messages and add the task to collection of active tasks
  • Monitor the active processing message's task
  • If a task completes with success status code delete message
  • While the message tasks are working periodically inform the source the message is still being processed.

Constructors

DefaultMessageManager(ISQSMessageCommunication, IHandlerInvoker, ILogger<DefaultMessageManager>, MessageManagerConfiguration)

Constructs an instance of DefaultMessageManager

public DefaultMessageManager(ISQSMessageCommunication sqsMessageCommunication, IHandlerInvoker handlerInvoker, ILogger<DefaultMessageManager> logger, MessageManagerConfiguration configuration)

Parameters

sqsMessageCommunication ISQSMessageCommunication

Provides APIs to communicate back to SQS and the associated Queue for incoming messages.

handlerInvoker IHandlerInvoker

Used to look up and invoke the correct handler for each message

logger ILogger<DefaultMessageManager>

Logger for debugging information

configuration MessageManagerConfiguration

The configuration for the message manager

Properties

ActiveMessageCount

The number of active messages being processed.

public int ActiveMessageCount { get; }

Property Value

int

Methods

ProcessMessageAsync(MessageEnvelope, SubscriberMapping, CancellationToken)

Start the async processing of a message.

public Task ProcessMessageAsync(MessageEnvelope messageEnvelope, SubscriberMapping subscriberMapping, CancellationToken token = default)

Parameters

messageEnvelope MessageEnvelope

The message to start processing

subscriberMapping SubscriberMapping

The mapping between the message's type and its handler

token CancellationToken

Optional token to cancel the message processing

Returns

Task

ProcessMessageGroupAsync(List<ConvertToEnvelopeResult>, string, CancellationToken)

Starts the async processing of messages within an ordered group. These messages are processed sequentially in the order in which they appear.

public Task ProcessMessageGroupAsync(List<ConvertToEnvelopeResult> messageGroup, string groupId, CancellationToken token = default)

Parameters

messageGroup List<ConvertToEnvelopeResult>

The ordered list of messages that will be processed sequentially

groupId string

The ID that uniquely identifies a message group

token CancellationToken

Optional token to cancel the message processing

Returns

Task

WaitAsync(TimeSpan)

Allows a poller to wait for when ActiveMessageCount is next decremented or when the timeout elapses

public Task WaitAsync(TimeSpan timeout)

Parameters

timeout TimeSpan

Maximum amount of time to wait

Returns

Task