Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
AWS SDK for Java version 2 - NYJavaSIG 2019-11-21
Search
sullis
November 21, 2019
Programming
0
99
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
Share
More Decks by sullis
See All by sullis
Amazon S3 NYJavaSIG 2024-12-12
sullis
0
100
Amazon S3 - Portland Java User Group 2024-09-17
sullis
0
64
Netty - Montreal Java User Group 2024-05-21
sullis
0
140
Netty Chicago Java User Group 2024-04-17
sullis
0
880
Java 21 - Portland Java User Group 2023-10-24
sullis
0
290
Microbenchmarking with JMH - Portland 2023-03-14
sullis
0
130
Code generation on the Java VM 2022-04-19
sullis
0
110
Mockito 2022-01-25
sullis
0
170
GitHub Actions 2021-12-16
sullis
0
37
Other Decks in Programming
See All in Programming
わたしの星のままで一番星になる ~ 出産を機にSIerからEC事業会社に転職した話 ~
kimura_m_29
0
180
Jakarta EE meets AI
ivargrimstad
0
250
Keeping it Ruby: Why Your Product Needs a Ruby SDK - RubyWorld 2024
envek
0
190
見えないメモリを観測する: PHP 8.4 `pg_result_memory_size()` とSQL結果のメモリ管理
kentaroutakeda
0
350
The Efficiency Paradox and How to Save Yourself and the World
hollycummins
1
440
CQRS+ES の力を使って効果を感じる / Feel the effects of using the power of CQRS+ES
seike460
PRO
0
130
17年周年のWebアプリケーションにTanStack Queryを導入する / Implementing TanStack Query in a 17th Anniversary Web Application
saitolume
0
250
これが俺の”自分戦略” プロセスを楽しんでいこう! - Developers CAREER Boost 2024
niftycorp
PRO
0
190
テスト自動化失敗から再挑戦しチームにオーナーシップを委譲した話/STAC2024 macho
ma_cho29
1
1.3k
PHPとAPI Platformで作る本格的なWeb APIアプリケーション(入門編) / phpcon 2024 Intro to API Platform
ttskch
0
240
ドメインイベント増えすぎ問題
h0r15h0
2
310
Итераторы в Go 1.23: зачем они нужны, как использовать, и насколько они быстрые?
lamodatech
0
770
Featured
See All Featured
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.3k
For a Future-Friendly Web
brad_frost
175
9.4k
Git: the NoSQL Database
bkeepers
PRO
427
64k
Imperfection Machines: The Place of Print at Facebook
scottboms
266
13k
A better future with KSS
kneath
238
17k
Reflections from 52 weeks, 52 projects
jeffersonlam
347
20k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
665
120k
[RailsConf 2023] Rails as a piece of cake
palkan
53
5k
A Tale of Four Properties
chriscoyier
157
23k
Java REST API Framework Comparison - PWX 2021
mraible
28
8.3k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
0
98
Visualization
eitanlees
146
15k
Transcript
Sean Sullivan November 21, 2019 NY JavaSIG AWS SDK for
Java version 2.x
software engineer Portland Oregon Java Scala About me
Agenda SDK for Java 2.x SDK internals Migrating from v1
to v2 Scala and SDK v2
AWS SDK for Java
SDK v2 announced June 2017 @awsforjava
“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
“The AWS SDK for Java 2.0 asynchronous client methods return
CompletableFuture objects” source: SDK v2 Developer Guide
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
Github projects aws-sdk-java aws-sdk-java-v2
SDK v2
Pull Request
SDK v2 Maven artifacts
https://search.maven.org/
<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
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
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
SDK v2 programming API • Immutable clients and models •
Enhanced pagination • Smart configuration merging • Forward-compatible enums • Streaming operations as first-class concepts
SDK internals
<slf4j.version>1.7.28</slf4j.version> <jackson.version>2.10.0</jackson.version> <netty.version>4.1.42.Final</netty.version> Transitive dependencies
“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/
Why code generation?
less boilerplate more consistency Why code generation?
class names parameter names method names exception names Consistency error
handling logging JSON serialization network I/O
AWS SDK for Java v2
JavaPoet AWS SDK for Java v2
Migrating code from v1 to v2
aws-secretsmanager-caching-java
https://github.com/aws/aws-secretsmanager-caching-java/
“AWS Secrets Manager Java caching client enables in-process caching of
secrets for Java applications” aws-secretsmanager-caching-java
aws-secretsmanager-caching-java is based on AWS SDK v1
https://github.com/aws/aws-secretsmanager-caching-java/issues/
how to migrate aws-secretsmanager- caching-java from SDK v1 to SDK
v2 ?
https://github.com/ aws/aws- secretsmanager- caching-java/pull/6
https://github.com/aws/aws-secretsmanager-caching-java/pull/6/files
https://github.com/aws/aws-secretsmanager-caching-java/pull/6/files
Scala and AWS SDK v2
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
import scala.compat.java8.FutureConverters._ import scala.collection.JavaConverters._
FutureConverters?
java.util.concurrent.CompletableFuture scala.concurrent.Future
FutureConverters.scala
migrating a Scala library from AWS SDK v1 to v2
“A tiny Scala wrapper around AWS CloudWatch Java client” gfc-aws-cloudwatch
https://github.com/gilt/gfc-aws-cloudwatch
https://github.com/ gilt/gfc-aws- cloudwatch/pull/8/ files
None
None
Conclusion SDK v1 — production ready SDK v2 — production
ready github.com/aws twitter.com/awsforjava
The end
None
Bonus material
“Hands-on in the AWS Java Ecosystem” AWS re:Invent 2018
“Developing Applications on AWS in the JVM” AWS re:Invent 2017
https://www.slideshare.net/AmazonWebServices/ dev205developing-applications-on-aws-in-the-jvm