Upgrade to Pro — share decks privately, control downloads, hide ads and more …

AWS SDK for Java version 2 - NYJavaSIG 2019-11-21

sullis
November 21, 2019

AWS SDK for Java version 2 - NYJavaSIG 2019-11-21

AWS SDK for Java version 2.x
NY JavaSIG
November 21, 2019

#nyjavasig
#awscloud
#awssdk
#java

sullis

November 21, 2019
Tweet

More Decks by sullis

Other Decks in Programming

Transcript

  1. “Under the hood, we use an HTTP client built on

    top of Netty to make the non- blocking HTTP call” “first class support for non-blocking I/O in our async clients” source: AWS Developer Blog
  2. “The AWS SDK for Java 2.0 asynchronous client methods return

    CompletableFuture objects” source: SDK v2 Developer Guide
  3. import java.util.concurrent.CompletableFuture; DynamoDBAsyncClient client = DynamoDBAsyncClient.builder() .region(Region.US_WEST_2) .build(); CompletableFuture<ListTablesResponse> response

    = client.listTables(ListTablesRequest.builder().build()); CompletableFuture<List<String>> tableNames = response.thenApply(ListTablesResponse::tableNames); tableNames.whenComplete((tables, err) -> { if (tables != null) { tables.forEach(System.out::println); } else { err.printStackTrace(); } }); SDK v2
  4. <dependency> <groupId>com.amazonaws<groupId> <artifactId>aws-java-sdk-dynamodb</artifactId> <version>1.11.679</version> </dependency> Maven dependencies SDK v1 <dependency>

    <groupId>software.amazon.awssdk<groupId> <artifactId>dynamodb</artifactId> <version>2.10.20</version> </dependency> SDK v2
  5. import com.amazonaws.services.cloudwatch.AmazonCloudWatchClient; import com.amazonaws.services.cloudwatch.AmazonCloudWatchClientBuilder; import com.amazonaws.services.cloudwatch.model.MetricDatum; import com.amazonaws.services.cloudwatch.model.PutMetricDataRequest; Java packages

    SDK v1 import software.amazon.awssdk.services.cloudwatch.CloudWatchAsyncClient; import software.amazon.awssdk.services.cloudwatch.model.MetricDatum; import software.amazon.awssdk.services.cloudwatch.model.PutMetricDataRequest; SDK v2
  6. distinct Maven artifact names distinct Java package names SDK v2

    and SDK v1 can co-exist in a Java application SDK v1 jar SDK v2 jar
  7. SDK v2 programming API • Immutable clients and models •

    Enhanced pagination • Smart configuration merging • Forward-compatible enums • Streaming operations as first-class concepts
  8. “To provide SDK support for the many services that AWS

    owns, the AWS SDKs make extensive use of code generation” Code generation https://aws.amazon.com/blogs/developer/aws-sdk-for-java-2-x-released/
  9. class names parameter names method names exception names Consistency error

    handling logging JSON serialization network I/O
  10. “AWS Secrets Manager Java caching client enables in-process caching of

    secrets for Java applications” aws-secretsmanager-caching-java
  11. val awsSdkVersion = “2.10.20” "org.scala-lang.modules" %% "scala-java8-compat" % “0.9.0", "software.amazon.awssdk"

    % "cloudwatch" % awsSdkVersion, "software.amazon.awssdk" % "dynamodb" % awsSdkVersion build.sbt
  12. Conclusion SDK v1 — production ready SDK v2 — production

    ready github.com/aws twitter.com/awsforjava