AWS Lambda Durable Execution SDK Examples

July 9, 2026 · View on GitHub

Example applications demonstrating the AWS Lambda Durable Execution SDK for Java.

Prerequisites

  • Java 17+
  • Maven 3.8+
  • AWS SAM CLI (for deployment)
  • AWS credentials configured

Local Testing

Run examples locally without deploying to AWS using LocalDurableTestRunner:

# Build and install the SDK to local Maven repo (required since SDK is not yet published)
mvn clean install -DskipTests   # from project root

cd examples

# Run all tests
mvn test

# Run specific test
mvn test -Dtest=SimpleStepExampleTest

The local runner executes in-memory and skips wait durations—ideal for fast iteration and CI/CD.

Deploy to AWS

cd examples
mvn clean package
sam build
sam deploy --guided

On first deploy, SAM will prompt for stack name and region. Subsequent deploys use saved config:

sam deploy

The SAM template configures:

  • DurableConfig with ExecutionTimeout and RetentionPeriodInDays
  • IAM permissions for lambda:CheckpointDurableExecutions and lambda:GetDurableExecutionState

Invoke Deployed Functions

sam remote invoke SimpleStepExampleFunction \
  --event '{"name":"World"}' \
  --stack-name durable-sdk-examples

Cloud Integration Tests

Run tests against deployed functions using CloudDurableTestRunner:

cd examples
mvn test -Dtest=CloudBasedIntegrationTest -Dtest.cloud.enabled=true

The tests auto-detect your AWS account and region from credentials. Override if needed:

mvn test -Dtest=CloudBasedIntegrationTest \
  -Dtest.cloud.enabled=true \
  -Dtest.aws.account=123456789012 \
  -Dtest.aws.region=us-east-1

Examples

ExampleDescription
SimpleStepExampleBasic sequential steps
WaitExampleSuspend execution with wait()
RetryExampleConfiguring retry strategies
ErrorHandlingExampleHandling StepFailedException and StepInterruptedException
GenericTypesExampleWorking with List<T> and Map<K,V>
CustomConfigExampleCustom Lambda client and SerDes
WaitAtLeastExampleConcurrent stepAsync() with wait()
WaitAsyncExampleNon-blocking waitAsync() with concurrent step
RetryInProcessExampleIn-process retry with concurrent operations
WaitAtLeastInProcessExampleWait completes before async step (no suspension)
ManyAsyncStepsExamplePerformance test with 500 concurrent async steps
SimpleMapExampleConcurrent map over a collection with durable steps
CustomShouldCompleteMapExampleCustom map completion with shouldComplete decisions
WaitForConditionExamplePoll a condition until met with waitForCondition()
OtelExampleOpenTelemetry instrumentation with logging span export
OtelXRayStepExampleExport step spans to X-Ray through the ADOT Lambda Layer
OtelXRayWaitExampleTrace a step-wait-step workflow across Lambda invocations
OtelXRayMapExampleTrace concurrent map operations and item steps in X-Ray
OtelXRayParallelExampleTrace parallel branches and branch steps in X-Ray
OtelXRayNestedContextExampleTrace nested child contexts and inner steps in X-Ray

Cleanup

sam delete