Skip to content

Commit

Permalink
Migrate batch example to use the aws crt client
Browse files Browse the repository at this point in the history
  • Loading branch information
jreijn committed Dec 22, 2023
1 parent 7475bed commit e4403a4
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
4 changes: 2 additions & 2 deletions examples/powertools-examples-batch/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<aspectj.version>1.9.20.1</aspectj.version>
<sdk.version>2.21.1</sdk.version>
<sdk.version>2.22.0</sdk.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -50,7 +50,7 @@
</dependency>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>url-connection-client</artifactId>
<artifactId>aws-crt-client</artifactId>
<version>${sdk.version}</version>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import software.amazon.awssdk.enhanced.dynamodb.model.BatchWriteItemEnhancedRequest;
import software.amazon.awssdk.enhanced.dynamodb.model.BatchWriteResult;
import software.amazon.awssdk.enhanced.dynamodb.model.WriteBatch;
import software.amazon.awssdk.http.urlconnection.UrlConnectionHttpClient;
import software.amazon.awssdk.services.dynamodb.DynamoDbClient;

public class DynamoDBWriter implements RequestHandler<ScheduledEvent, String> {
Expand All @@ -30,7 +29,7 @@ public class DynamoDBWriter implements RequestHandler<ScheduledEvent, String> {
public DynamoDBWriter() {
random = new SecureRandom();
DynamoDbClient dynamoDbClient = DynamoDbClient.builder()
.httpClientBuilder(UrlConnectionHttpClient.builder())
.httpClientBuilder(AwsCrtHttpClient.builder())
.build();

enhancedClient = DynamoDbEnhancedClient.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import org.slf4j.LoggerFactory;
import org.demo.batch.model.Product;
import software.amazon.awssdk.core.SdkBytes;
import software.amazon.awssdk.http.urlconnection.UrlConnectionHttpClient;
import software.amazon.awssdk.http.crt.AwsCrtHttpClient;
import software.amazon.awssdk.services.kinesis.KinesisClient;
import software.amazon.awssdk.services.kinesis.model.PutRecordsRequest;
import software.amazon.awssdk.services.kinesis.model.PutRecordsRequestEntry;
Expand All @@ -36,7 +36,7 @@ public class KinesisBatchSender implements RequestHandler<ScheduledEvent, String

public KinesisBatchSender() {
kinesisClient = KinesisClient.builder()
.httpClient(UrlConnectionHttpClient.create())
.httpClient(AwsCrtHttpClient.create())
.build();
random = new SecureRandom();
objectMapper = new ObjectMapper();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.demo.batch.model.Product;
import software.amazon.awssdk.http.urlconnection.UrlConnectionHttpClient;
import software.amazon.awssdk.http.crt.AwsCrtHttpClient;
import software.amazon.awssdk.services.sqs.SqsClient;
import software.amazon.awssdk.services.sqs.model.SendMessageBatchRequest;
import software.amazon.awssdk.services.sqs.model.SendMessageBatchRequestEntry;
Expand All @@ -35,7 +35,7 @@ public class SqsBatchSender implements RequestHandler<ScheduledEvent, String> {

public SqsBatchSender() {
sqsClient = SqsClient.builder()
.httpClient(UrlConnectionHttpClient.create())
.httpClient(AwsCrtHttpClient.create())
.build();
random = new SecureRandom();
objectMapper = new ObjectMapper();
Expand Down

0 comments on commit e4403a4

Please sign in to comment.