Show / Hide Table of Contents

Class ALambdaQueueFunction<TMessage>

The ALambdaQueueFunction<TMessage> is the abstract base class for handling Amazon Simple Queue Service (SQS) events.

Inheritance
System.Object
ALambdaFunction
ALambdaQueueFunction<TMessage>
Implements
ILambdaSharpLogger
Inherited Members
ALambdaFunction.UtcNow
ALambdaFunction.Info
ALambdaFunction.ErrorReportGenerator
ALambdaFunction.Logger
ALambdaFunction.CurrentContext
ALambdaFunction.HttpClient
ALambdaFunction.DebugLoggingEnabled
ALambdaFunction.InitializeAsync(LambdaConfig)
ALambdaFunction.FunctionHandlerAsync(Stream, ILambdaContext)
ALambdaFunction.InitializePrologueAsync(ILambdaConfigSource)
ALambdaFunction.InitializeEpilogueAsync()
ALambdaFunction.HandleFailedInitializationAsync(Stream)
ALambdaFunction.RecordFailedMessageAsync(LambdaLogLevel, ALambdaFunction.FailedMessageOrigin, String, Exception)
ALambdaFunction.DecryptSecretAsync(String, Dictionary<String, String>, CancellationToken)
ALambdaFunction.EncryptSecretAsync(String, String, Dictionary<String, String>, CancellationToken)
ALambdaFunction.AddPendingTask(Task)
ALambdaFunction.RunTask(Action, CancellationToken)
ALambdaFunction.RunTask(Func<Task>, CancellationToken)
ALambdaFunction.ForceLambdaColdStart(String)
ALambdaFunction.TerminateLambdaInstance(String)
ALambdaFunction.RecordErrorReport(LambdaErrorReport)
ALambdaFunction.RecordException(Exception)
ALambdaFunction.LogDebug(String, Object[])
ALambdaFunction.LogInfo(String, Object[])
ALambdaFunction.LogWarn(String, Object[])
ALambdaFunction.LogError(Exception)
ALambdaFunction.LogError(Exception, String, Object[])
ALambdaFunction.LogErrorAsInfo(Exception)
ALambdaFunction.LogErrorAsInfo(Exception, String, Object[])
ALambdaFunction.LogErrorAsWarning(Exception)
ALambdaFunction.LogErrorAsWarning(Exception, String, Object[])
ALambdaFunction.LogFatal(Exception, String, Object[])
ALambdaFunction.LogMetric(String, Double, LambdaMetricUnit)
ALambdaFunction.LogMetric(String, Double, LambdaMetricUnit, IEnumerable<String>, Dictionary<String, String>)
ALambdaFunction.LogMetric(IEnumerable<LambdaMetric>)
ALambdaFunction.LogMetric(IEnumerable<LambdaMetric>, IEnumerable<String>, Dictionary<String, String>)
ALambdaFunction.LogEvent<T>(T, IEnumerable<String>)
ALambdaFunction.LogEvent<T>(String, T, IEnumerable<String>)
ALambdaFunction.LogEvent<T>(String, String, T, IEnumerable<String>)
ALambdaFunction.ILambdaSharpLogger.DebugLoggingEnabled
ALambdaFunction.ILambdaSharpLogger.Info
ALambdaFunction.ILambdaSharpLogger.Log(LambdaLogLevel, Exception, String, Object[])
ALambdaFunction.ILambdaSharpLogger.LogRecord(ALambdaLogRecord)
Namespace: LambdaSharp.SimpleQueueService
Assembly: LambdaSharp.SimpleQueueService.dll
Syntax
public abstract class ALambdaQueueFunction<TMessage> : ALambdaFunction, ILambdaSharpLogger
Type Parameters
Name Description
TMessage

The SQS queue message type.

Remarks

When the Lambda function is declared with a Dead-Letter Queue (DLQ), the function attempts a failed message up to 3 times, by default. The default can be overridden by setting a different value for the MAX_QUEUE_RETRIES environment variable. Without a DLQ, the function will attempt a message indefinitely.

Constructors

ALambdaQueueFunction(ILambdaJsonSerializer)

Initializes a new ALambdaQueueFunction<TMessage> instance using the default implementation of ILambdaQueueFunctionDependencyProvider.

Declaration
protected ALambdaQueueFunction(ILambdaJsonSerializer serializer)
Parameters
Type Name Description
ILambdaJsonSerializer serializer

Custom implementation of ILambdaJsonSerializer.

ALambdaQueueFunction(ILambdaJsonSerializer, ILambdaQueueFunctionDependencyProvider)

Initializes a new ALambdaQueueFunction<TMessage> instance using a custom implementation of ILambdaQueueFunctionDependencyProvider.

Declaration
protected ALambdaQueueFunction(ILambdaJsonSerializer serializer, ILambdaQueueFunctionDependencyProvider provider)
Parameters
Type Name Description
ILambdaJsonSerializer serializer

Custom implementation of ILambdaJsonSerializer.

ILambdaQueueFunctionDependencyProvider provider

Custom implementation of ILambdaQueueFunctionDependencyProvider.

Properties

CurrentRecord

The CurrentRecord property holds the SQS queue message record that is currently being processed.

Declaration
protected SQSEvent.SQSMessage CurrentRecord { get; }
Property Value
Type Description
Amazon.Lambda.SQSEvents.SQSEvent.SQSMessage

The Amazon.Lambda.SQSEvents.SQSEvent.SQSMessage instance.

Remarks

This property is only set during the invocation of ProcessMessageStreamAsync(Stream). Otherwise, it returns null.

LambdaSerializer

An instance of ILambdaJsonSerializer used for serializing/deserializing JSON data.

Declaration
protected ILambdaJsonSerializer LambdaSerializer { get; }
Property Value
Type Description
ILambdaJsonSerializer

The ILambdaJsonSerializer instance.

Provider

The ILambdaQueueFunctionDependencyProvider instance used by the Lambda function to satisfy its required dependencies.

Declaration
protected ILambdaQueueFunctionDependencyProvider Provider { get; }
Property Value
Type Description
ILambdaQueueFunctionDependencyProvider

The ILambdaQueueFunctionDependencyProvider instance.

Methods

Deserialize(String)

The Deserialize(String) method converts the SQS queue message from string to a typed instance.

Declaration
public virtual TMessage Deserialize(string body)
Parameters
Type Name Description
System.String body

The SQS queue message.

Returns
Type Description
TMessage

The deserialized SQS queue message.

Remarks

This method invokes Amazon.Lambda.Core.ILambdaSerializer.Deserialize``1(System.IO.Stream) to convert the SQS queue message string into a instance. Override this method to provide a custom message deserialization implementation.

ProcessMessageAsync(TMessage)

The ProcessMessageAsync(TMessage) method is invoked for every received SQS queue message.

Declaration
public abstract Task ProcessMessageAsync(TMessage message)
Parameters
Type Name Description
TMessage message

The deserialized SQS queue message.

Returns
Type Description
System.Threading.Tasks.Task

The task object representing the asynchronous operation.

ProcessMessageStreamAsync(Stream)

The ProcessMessageStreamAsync(Stream) method is overridden to provide specific behavior for this base class.

Declaration
public sealed override async Task<Stream> ProcessMessageStreamAsync(Stream stream)
Parameters
Type Name Description
System.IO.Stream stream

The stream with the request payload.

Returns
Type Description
System.Threading.Tasks.Task<System.IO.Stream>

The task object representing the asynchronous operation.

Overrides
ALambdaFunction.ProcessMessageStreamAsync(Stream)
Remarks

This method cannot be overridden.

Implements

ILambdaSharpLogger
In This Article
Back to top Generated by DocFX