File tree Expand file tree Collapse file tree
sdk/src/main/java/com/amazonaws/lambda/durable Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1515import software .amazon .awssdk .core .SdkSystemSetting ;
1616import software .amazon .awssdk .regions .Region ;
1717import software .amazon .awssdk .services .lambda .LambdaClient ;
18+ import software .amazon .awssdk .services .lambda .model .GetDurableExecutionStateRequest ;
1819
1920/**
2021 * Configuration for DurableHandler initialization. This class provides a builder pattern for configuring SDK components
@@ -152,6 +153,22 @@ private static DurableExecutionClient createDefaultDurableExecutionClient() {
152153 .region (Region .of (region ))
153154 .build ();
154155
156+ try {
157+ // Make a dummy call to prime the SDK client. This leads to faster first call times because the HTTP client
158+ // is already warmed up when the handler executes. More details, see here:
159+ // https://github.com/aws/aws-sdk-java-v2/issues/1340
160+ // https://github.com/aws/aws-sdk-java-v2/issues/3801
161+ lambdaClient .getDurableExecutionState (GetDurableExecutionStateRequest .builder ()
162+ .checkpointToken ("dummyToken" )
163+ .durableExecutionArn (String .format (
164+ "arn:aws:lambda:%s:123456789012:function:dummy:$LATEST/durable-execution/a0c9cbab-3de6-49ea-8630-0ef3bb4874e4/ed8a29c0-6216-3f4a-ad2e-24e2ad70b2d6" ,
165+ region ))
166+ .maxItems (0 )
167+ .build ());
168+ } catch (Exception e ) {
169+ // Ignore exceptions since this is a dummy call to prime the SDK client for faster startup times
170+ }
171+
155172 logger .debug ("Default DurableExecutionClient created for region: {}" , region );
156173 return new LambdaDurableFunctionsClient (lambdaClient );
157174 }
You can’t perform that action at this time.
0 commit comments