SlideShare a Scribd company logo
1 of 24
Download to read offline
Revolutionize Java Database App
Development with Reactive Streams and
Virtual Threads
jPrime 2023
Juarez Barbosa Junior @juarezjunior
Sr. Principal Java Developer Evangelist
ORACLE
Copyright © 2023, Oracle and/or its affiliates
Agenda
• Java App Dev with Oracle Database
• Support for the Latest Java Versions
• Overview of Oracle DB Access with Java
• Oracle JDBC – Sync and Async
• Classic Java Platform Threads
• Project Loom – Virtual Threads
• Virtual Threads - JEPs 425, 436, 444
• Demo # 1: Virtual vs Platform Threads
• Reactive JDBC - Synchronous vs Asynchronous JDBC
• Reactive Streams Ingestion (RSI)
• Demo # 2: Reactive Streams Ingestion (RSI)
• From Sync to Reactive JDBC: Oracle R2DBC
• Demo # 3: Oracle R2DBC with Project Reactor
• Live Labs/Free Oracle Cloud Account/Oracle ACE Program
Copyright © 2023, Oracle and/or its affiliates
Copyright © 2023, Oracle and/or its affiliates
Java App Dev with Oracle Database
Copyright © 2023, Oracle and/or its affiliates
Support for the Latest Java Versions
• Java 11 - native support, compiled with it
• Java 17 - certified
• JDBC Standards - 4.2 and 4.3
• GraalVM - native image instrumentation
• Reactive Streams - Java Flow API support
• Project Loom - Virtual Threads support
• Data access is critical in mission-critical apps
Copyright © 2023, Oracle and/or its affiliates
Overview of Oracle DB Access with Java
User
Java
Code
JDBC
Reactive
Extension Standard
JDBC API
R2DBC
+
3rd party
Reactive
Streams
Libraries
Async call with non-blocking
backpressure
operators (map, reduce, filters),
concurrency modeling,
monitoring, tracing
Implements Java SE
reactive stream
interface (Flow)
Full Reactive
Streams
Sync/blocking JDBC calls
Java
Business
Logic
User Java code
Oracle
Database
Oracle JDBC
driver
VTs/lightweight JDBC calls
Copyright © 2022, Oracle and/or its affiliates
Oracle JDBC – Async and Sync
⚫ Project Loom/Virtual Threads
− Synchronous database access with lightweight threads
− Standard JDBC + Virtual Threads
− Client application call stack may use conventional (synchronous) code
− Libraries must be compatible with Virtual Threads
− Oracle instrumented the Oracle JDBC 21c driver to support Virtual Threads
⚫ Reactive Programming
− Asynchronous database access with non-blocking network I/O
− Oracle Reactive Streams Ingestion + Oracle R2DBC + Oracle JDBC Reactive Extensions
− Application call stack must be fully asynchronous
− Libraries are available: Reactor, RxJava, Akka, Vert.x
Copyright © 2023, Oracle and/or its affiliates
Classic Java Platform Threads
⚫ Database access with blocking threads
⚫ A JDBC call blocks a thread for 100’s of milliseconds (thread-per-request style)
⚫ Thread count increases linearly with the number of JDBC calls
⚫ Performance degrades as the number of threads increases
⚫ 1 MB of stack memory per thread
⚫ Scheduling many platform threads is expensive
⚫ Preemptive scheduling vs time-slicing
Copyright © 2022, Oracle and/or its affiliates
Virtual Threads - JEPs 425, 436, 444
⚫ Virtual Threads – JEPs (JDK Enhancement Proposals)
⚫ Lightweight threads that dramatically reduce the effort of writing, maintaining, and
observing high-throughput concurrent applications
⚫ Enable applications written in the simple thread-per-request style to scale with near-
optimal hardware utilization
⚫ Enable easy troubleshooting, debugging, and profiling of virtual threads with existing
JDK tools
⚫ Do not remove the traditional implementation of threads
⚫ Do not alter the basic concurrency model of Java
⚫ Enable existing code that uses Java threads (java.lang.Thread, etc) to adopt virtual
threads with minimal change
Copyright © 2023, Oracle and/or its affiliates
Virtual Threads - JEPs 425, 436, 444
⚫ java.lang.Thread
⚫ final Boolean - isVirtual()
⚫ static Thread.Builder.OfVirtual - ofVirtual()
⚫ static Thread.Builder.OfPlatform - ofPlatform()
⚫ static Thread - startVirtualThread(Runnable task)
⚫ java.util.concurrent.Executors
⚫ static ExecutorService - newVirtualThreadPerTaskExecutor()
Copyright © 2022, Oracle and/or its affiliates
Demo # 1: Virtual vs Platform Threads
⚫ Virtual Threads versus Platform Threads
⚫ JEP 425 Virtual Threads (Preview)
⚫ JEP 436 (Second Preview)
⚫ JEP 444 (Target -> JDK 21)
⚫ Runs on Java 19, 20, 21
⚫ javac --release 19 --enable-preview
⚫ java --enable-preview
⚫ Oracle JDBC Driver 21c instrumented to support Virtual Threads
⚫ Verifiable comparison of OS/HW resources consumption (Platform Threads x Virtual
Threads)
Copyright © 2023, Oracle and/or its affiliates
Reactive JDBC - Sync vs Async JDBC
Setup
Blocking
Handle Result
Setup
Non-Blocking
Handle Result
Synchronous JDBC Setup
Blocking
Handle Result
Setup
Non-Blocking
Handle Result
Setup
Non-Blocking
Handle Result
Reactive JDBC
Database
Setup
Blocking
Handle Result
Database
Copyright © 2022, Oracle and/or its affiliates
Reactive Streams Ingestion (RSI)
⚫ Java Library for Reactive Streams Ingestion
⚫ Streaming capability: Ingest data in an unblocking, and
reactive way from a large group of clients
⚫ Group records through RAC (Real App Clusters),
and Shard affinity using native UCP (Universal Connection
Pool)
⚫ Optimize CPU allocation while decoupling record
Processing from I/O
⚫ Fastest insert method for the Oracle Database through
Direct Path Insert, bypassing SQL and writing directly into the DB files
Copyright © 2023, Oracle and/or its affiliates
Demo # 2: Reactive Streams Ingestion (RSI)
Container
Pipelines,
Jenkins, etc.
Build
Test
Push
Push Docker
images to
Registry
Cloud
Infrastructur
e Registry
Container
Engine for
Kubernetes
Pull images
from Registry
Deploy
images to
production
Kubernetes
worker nodes
Containers
running
microservices
deployed over
Kubernetes
ORACLE CLOUD INFRASTRUCTURE
ATP, ADW, ATP-D,
AFDW-D
Memoptimized
Rowstore
RSI Runtime: Non-
blocking, optimized library
for streaming data
through Direct Path, Shard
& RAC/FAN support.
HTTP / REST Engine over
Helidon
Define build
for CI/CD
toolchain
gRPC / AMQP / MQTT
Engines
Microservices
Files / Logs
IoT
Devices
/
Apps
cv
MQTT
gRPC
AMQP
HTTP / REST
JDBC
Direct Path
INSERT
Record
Streaming
over
multiple
protocols.
Copyright © 2022, Oracle and/or its affiliates
Oracle R2DBC
⚫ Oracle Reactive Relational Database Connectivity (R2DBC)
⚫ Oracle R2DBC Driver is a Java library that supports reactive
Programming with Oracle Database
⚫ It implements the R2DBC Service Provider Interface (SPI) as
specified by the Reactive Relational Database Connectivity (R2DBC)
⚫ The R2DBC SPI exposes Reactive Streams as an abstraction for
Remote database operations
⚫ The sample code uses Project Reactor. It could use RxJava, Akka,
or any RS library
⚫ Runs on Java 11+
Copyright © 2023, Oracle and/or its affiliates
From Sync to Reactive JDBC: Oracle R2DBC
static String queryJdbc(java.sql.Connection connection) throws
SQLException {
try (java.sql.Statement statement = connection.createStatement()) {
ResultSet resultSet =
statement.executeQuery("SELECT * FROM CUSTOMERS");
if (resultSet.next())
return resultSet.getString(1);
else
throw new NoSuchElementException("Query returned zero rows");
}
}
static Publisher<String> queryR2dbc(io.r2dbc.spi.Connection
connection) {
return Flux.from(connection.createStatement(
"SELECT * FROM CUSTOMERS")
.execute())
.flatMap(result ->
result.map(row -> row.get(0, String.class)))
.switchIfEmpty(Flux.error(
new NoSuchElementException("Query returned zero rows")));
}
Virtual Threads or
Reactive?
• Oracle JDBC supports both!
• Want Virtual Threads?
• Oracle JDBC has been “Virtual
Thread Compatible” since 21.1.0.0
• Want Reactive?
• Oracle R2DBC 1.0.0 is available now
• Consume Flow interfaces directly
from Oracle JDBC’s Reactive
Extensions
Copyright © 2023, Oracle and/or its affiliates
Virtual Threads or Reactive?
• Benefits of Virtual Threads:
• Easier to read and write
• Easier to debug
• Integration with JDK tools
• Do not alter the basic concurrency model of Java
• Limitations of Virtual Threads:
• Some libraries are not compatible
• Still not in GA –> JDK 21
• JEP 425: Virtual Threads (Preview)
• JEP 436: Virtual Threads (Second Preview)
• JEP 444: Virtual Threads
Copyright © 2023, Oracle and/or its affiliates
Benefits of Reactive:
• Reactive Libraries (Reactor, RxJava, Akka, Vert.x)
• Stream-like API with a functional style
• Low-level concurrency is handled for you
(locks, atomics, queues).
Limitations of Reactive:
• Steep learning curve
• Harder to read and write
• Harder to debug
Copyright © 2023, Oracle and/or its affiliates
References
• Project Loom / Virtual Threads
• Loom - https://openjdk.org/projects/loom/
• JEP 444 Virtual Threads (Targeted) - https://openjdk.org/jeps/444
• Introduction to Oracle JDBC 21c Driver Support for Virtual Threads - https://bit.ly/3UlNJWP
• Reactive Streams Ingestion Library
• Getting Started with the Java library for Reactive Streams Ingestion (RSI) -
https://bit.ly/3rEiRnC
• High-throughput stream processing with the Java Library for Reactive Streams Ingestion (RSI),
Virtual Threads, and the Oracle ATP Database - https://bit.ly/3rATCTd
• RSI - https://docs.oracle.com/en/database/oracle/
• R2DBC
• Oracle R2DBC Driver – https://github.com/oracle/oracle-r2dbc
• Develop Java applications with Oracle Database
• JDBC – https://www.oracle.com/database/technologies/appdev/jdbc.html
Oracle
Database
23c Oracle Database 23c Free – Developer Edition
available for download now
• Oracle Database 23c accelerates Oracle’s
mission to make it simple to develop and
run all data-driven apps
• Provides developers easy early access to
23c app dev features
• Limited database size, memory, CPU
threads (same limits as Express Edition)
Free Developer Release
http://oracle.com/23cFree
http://oracle.com/23cFree
Oracle LiveLabs
Showcasing how Oracle’s solutions can
solve your business problems
500+
free workshops,
available or in
development
3.5 million
people have already visited
LiveLabs
developer.oracle.com/livelabs
learn something new …at your pace!
600+
events run
using LiveLabs
workshops
3 membership tiers
Connect: @oracleace facebook.com/OracleACEs
aceprogram_ww@oracle.com
500+ technical experts &
community leaders helping peers globally
The Oracle ACE Program recognizes & rewards individuals for
their technical & community contributions to the Oracle community
Nominate
yourself or a candidate:
ace.oracle.com/nominate
Learn more - ace.oracle.com
blogs.oracle.com/ace
Create your FREE
Cloud Account
• Go to
https://signup.cloud.oracle.com/
Copyright © 2023, Oracle and/or its affiliates
About me
• Juarez Barbosa Junior - @juarezjunior
• Senior Principal Java Developer Evangelist
• 27 years of experience
• SW Engineering, Developer Relations
• Microsoft, Oracle, IBM, Nokia, Unisys, Accenture, and a
few startups
• Microsoft Azure Developer Relations Lead
• IBM Watson Tech Evangelist & Cloud Rockstar
• IBM Mobile Tech Evangelist & Global Thought Leader
• Nokia Developers Global Champion
• Lead Software/DevOps Architect
• Expertise
• Java, Cloud, DevOps, Cloud-native, Blockchain
Copyright © 2023, Oracle and/or its affiliates
Thank you!
24
Copyright © 2023, Oracle and/or its affiliates | Confidential: Internal

More Related Content

Similar to jPrime 2023 - Revolutionize Java DB AppDev with Reactive Streams and Virtual Threads

CloudLand - A High-Speed Data Ingestion Service in Java Using MQTT, AMQP, and...
CloudLand - A High-Speed Data Ingestion Service in Java Using MQTT, AMQP, and...CloudLand - A High-Speed Data Ingestion Service in Java Using MQTT, AMQP, and...
CloudLand - A High-Speed Data Ingestion Service in Java Using MQTT, AMQP, and...Juarez Junior
 
DWX23 - A High-Speed Data Ingestion Service in Java Using MQTT, AMQP, and STO...
DWX23 - A High-Speed Data Ingestion Service in Java Using MQTT, AMQP, and STO...DWX23 - A High-Speed Data Ingestion Service in Java Using MQTT, AMQP, and STO...
DWX23 - A High-Speed Data Ingestion Service in Java Using MQTT, AMQP, and STO...Juarez Junior
 
BarcelonaJUG - A High-Speed Data Ingestion Service in Java Using MQTT, AMQP, ...
BarcelonaJUG - A High-Speed Data Ingestion Service in Java Using MQTT, AMQP, ...BarcelonaJUG - A High-Speed Data Ingestion Service in Java Using MQTT, AMQP, ...
BarcelonaJUG - A High-Speed Data Ingestion Service in Java Using MQTT, AMQP, ...Juarez Junior
 
Oracle CloudWorld 2023 - A High-Speed Data Ingestion Service in Java Using MQ...
Oracle CloudWorld 2023 - A High-Speed Data Ingestion Service in Java Using MQ...Oracle CloudWorld 2023 - A High-Speed Data Ingestion Service in Java Using MQ...
Oracle CloudWorld 2023 - A High-Speed Data Ingestion Service in Java Using MQ...Juarez Junior
 
Cloud Conference Day - A High-Speed Data Ingestion Service in Java Using MQTT...
Cloud Conference Day - A High-Speed Data Ingestion Service in Java Using MQTT...Cloud Conference Day - A High-Speed Data Ingestion Service in Java Using MQTT...
Cloud Conference Day - A High-Speed Data Ingestion Service in Java Using MQTT...Juarez Junior
 
DeveloperWeek Latin America 2023 - A High-Speed Data Ingestion Service in Jav...
DeveloperWeek Latin America 2023 - A High-Speed Data Ingestion Service in Jav...DeveloperWeek Latin America 2023 - A High-Speed Data Ingestion Service in Jav...
DeveloperWeek Latin America 2023 - A High-Speed Data Ingestion Service in Jav...Juarez Junior
 
Melee Numerique 2022 - Revolutionize Java DB App Dev with Reactive Streams an...
Melee Numerique 2022 - Revolutionize Java DB App Dev with Reactive Streams an...Melee Numerique 2022 - Revolutionize Java DB App Dev with Reactive Streams an...
Melee Numerique 2022 - Revolutionize Java DB App Dev with Reactive Streams an...Juarez Junior
 
Rollin onj Rubyv3
Rollin onj Rubyv3Rollin onj Rubyv3
Rollin onj Rubyv3Oracle
 
TDC Connections 2023 - A High-Speed Data Ingestion Service in Java Using MQTT...
TDC Connections 2023 - A High-Speed Data Ingestion Service in Java Using MQTT...TDC Connections 2023 - A High-Speed Data Ingestion Service in Java Using MQTT...
TDC Connections 2023 - A High-Speed Data Ingestion Service in Java Using MQTT...Juarez Junior
 
What's New and Noteworthy on Oracle CAF 12.1.3
What's New and Noteworthy on Oracle CAF 12.1.3What's New and Noteworthy on Oracle CAF 12.1.3
What's New and Noteworthy on Oracle CAF 12.1.3Bruno Borges
 
Silicon Valley JUG meetup July 18, 2018
Silicon Valley JUG meetup July 18, 2018Silicon Valley JUG meetup July 18, 2018
Silicon Valley JUG meetup July 18, 2018Oracle Developers
 
ADBA (Asynchronous Database Access)
ADBA (Asynchronous Database Access)ADBA (Asynchronous Database Access)
ADBA (Asynchronous Database Access)Logico
 
JavaOne 2014 Java EE 8 Booth Slides
JavaOne 2014 Java EE 8 Booth SlidesJavaOne 2014 Java EE 8 Booth Slides
JavaOne 2014 Java EE 8 Booth SlidesEdward Burns
 
The Making of the Oracle R2DBC Driver and How to Take Your Code from Synchron...
The Making of the Oracle R2DBC Driver and How to Take Your Code from Synchron...The Making of the Oracle R2DBC Driver and How to Take Your Code from Synchron...
The Making of the Oracle R2DBC Driver and How to Take Your Code from Synchron...VMware Tanzu
 
java database connectivity for java programming
java database connectivity for java programmingjava database connectivity for java programming
java database connectivity for java programmingrinky1234
 
How Java 19 Influences the Future of Your High-Scale Applications .pdf
How Java 19 Influences the Future of Your High-Scale Applications .pdfHow Java 19 Influences the Future of Your High-Scale Applications .pdf
How Java 19 Influences the Future of Your High-Scale Applications .pdfAna-Maria Mihalceanu
 
Server Side JavaScript on the Java Platform - David Delabassee
Server Side JavaScript on the Java Platform - David DelabasseeServer Side JavaScript on the Java Platform - David Delabassee
Server Side JavaScript on the Java Platform - David DelabasseeJAXLondon2014
 
Java 40 versions_sgp
Java 40 versions_sgpJava 40 versions_sgp
Java 40 versions_sgpmichaelisvy
 

Similar to jPrime 2023 - Revolutionize Java DB AppDev with Reactive Streams and Virtual Threads (20)

CloudLand - A High-Speed Data Ingestion Service in Java Using MQTT, AMQP, and...
CloudLand - A High-Speed Data Ingestion Service in Java Using MQTT, AMQP, and...CloudLand - A High-Speed Data Ingestion Service in Java Using MQTT, AMQP, and...
CloudLand - A High-Speed Data Ingestion Service in Java Using MQTT, AMQP, and...
 
DWX23 - A High-Speed Data Ingestion Service in Java Using MQTT, AMQP, and STO...
DWX23 - A High-Speed Data Ingestion Service in Java Using MQTT, AMQP, and STO...DWX23 - A High-Speed Data Ingestion Service in Java Using MQTT, AMQP, and STO...
DWX23 - A High-Speed Data Ingestion Service in Java Using MQTT, AMQP, and STO...
 
BarcelonaJUG - A High-Speed Data Ingestion Service in Java Using MQTT, AMQP, ...
BarcelonaJUG - A High-Speed Data Ingestion Service in Java Using MQTT, AMQP, ...BarcelonaJUG - A High-Speed Data Ingestion Service in Java Using MQTT, AMQP, ...
BarcelonaJUG - A High-Speed Data Ingestion Service in Java Using MQTT, AMQP, ...
 
Oracle CloudWorld 2023 - A High-Speed Data Ingestion Service in Java Using MQ...
Oracle CloudWorld 2023 - A High-Speed Data Ingestion Service in Java Using MQ...Oracle CloudWorld 2023 - A High-Speed Data Ingestion Service in Java Using MQ...
Oracle CloudWorld 2023 - A High-Speed Data Ingestion Service in Java Using MQ...
 
Cloud Conference Day - A High-Speed Data Ingestion Service in Java Using MQTT...
Cloud Conference Day - A High-Speed Data Ingestion Service in Java Using MQTT...Cloud Conference Day - A High-Speed Data Ingestion Service in Java Using MQTT...
Cloud Conference Day - A High-Speed Data Ingestion Service in Java Using MQTT...
 
DeveloperWeek Latin America 2023 - A High-Speed Data Ingestion Service in Jav...
DeveloperWeek Latin America 2023 - A High-Speed Data Ingestion Service in Jav...DeveloperWeek Latin America 2023 - A High-Speed Data Ingestion Service in Jav...
DeveloperWeek Latin America 2023 - A High-Speed Data Ingestion Service in Jav...
 
Melee Numerique 2022 - Revolutionize Java DB App Dev with Reactive Streams an...
Melee Numerique 2022 - Revolutionize Java DB App Dev with Reactive Streams an...Melee Numerique 2022 - Revolutionize Java DB App Dev with Reactive Streams an...
Melee Numerique 2022 - Revolutionize Java DB App Dev with Reactive Streams an...
 
Rollin onj Rubyv3
Rollin onj Rubyv3Rollin onj Rubyv3
Rollin onj Rubyv3
 
TDC Connections 2023 - A High-Speed Data Ingestion Service in Java Using MQTT...
TDC Connections 2023 - A High-Speed Data Ingestion Service in Java Using MQTT...TDC Connections 2023 - A High-Speed Data Ingestion Service in Java Using MQTT...
TDC Connections 2023 - A High-Speed Data Ingestion Service in Java Using MQTT...
 
What's New and Noteworthy on Oracle CAF 12.1.3
What's New and Noteworthy on Oracle CAF 12.1.3What's New and Noteworthy on Oracle CAF 12.1.3
What's New and Noteworthy on Oracle CAF 12.1.3
 
Silicon Valley JUG meetup July 18, 2018
Silicon Valley JUG meetup July 18, 2018Silicon Valley JUG meetup July 18, 2018
Silicon Valley JUG meetup July 18, 2018
 
ADBA (Asynchronous Database Access)
ADBA (Asynchronous Database Access)ADBA (Asynchronous Database Access)
ADBA (Asynchronous Database Access)
 
JavaOne 2014 Java EE 8 Booth Slides
JavaOne 2014 Java EE 8 Booth SlidesJavaOne 2014 Java EE 8 Booth Slides
JavaOne 2014 Java EE 8 Booth Slides
 
The Making of the Oracle R2DBC Driver and How to Take Your Code from Synchron...
The Making of the Oracle R2DBC Driver and How to Take Your Code from Synchron...The Making of the Oracle R2DBC Driver and How to Take Your Code from Synchron...
The Making of the Oracle R2DBC Driver and How to Take Your Code from Synchron...
 
java database connectivity for java programming
java database connectivity for java programmingjava database connectivity for java programming
java database connectivity for java programming
 
Oracle History #5
Oracle History #5Oracle History #5
Oracle History #5
 
How Java 19 Influences the Future of Your High-Scale Applications .pdf
How Java 19 Influences the Future of Your High-Scale Applications .pdfHow Java 19 Influences the Future of Your High-Scale Applications .pdf
How Java 19 Influences the Future of Your High-Scale Applications .pdf
 
Jdbc
JdbcJdbc
Jdbc
 
Server Side JavaScript on the Java Platform - David Delabassee
Server Side JavaScript on the Java Platform - David DelabasseeServer Side JavaScript on the Java Platform - David Delabassee
Server Side JavaScript on the Java Platform - David Delabassee
 
Java 40 versions_sgp
Java 40 versions_sgpJava 40 versions_sgp
Java 40 versions_sgp
 

More from Juarez Junior

Oracle CloudWorld 2023 - How to hook up Telegram with Spring Boot and ADB
Oracle CloudWorld 2023 - How to hook up Telegram with Spring Boot and ADBOracle CloudWorld 2023 - How to hook up Telegram with Spring Boot and ADB
Oracle CloudWorld 2023 - How to hook up Telegram with Spring Boot and ADBJuarez Junior
 
Oracle CloudWorld 2023 - A Practical Guide to Implementing DevOps with IaC fo...
Oracle CloudWorld 2023 - A Practical Guide to Implementing DevOps with IaC fo...Oracle CloudWorld 2023 - A Practical Guide to Implementing DevOps with IaC fo...
Oracle CloudWorld 2023 - A Practical Guide to Implementing DevOps with IaC fo...Juarez Junior
 
Oracle CloudWorld 2023 - Multi-cloud App Dev for Java Devs with Microsoft Azu...
Oracle CloudWorld 2023 - Multi-cloud App Dev for Java Devs with Microsoft Azu...Oracle CloudWorld 2023 - Multi-cloud App Dev for Java Devs with Microsoft Azu...
Oracle CloudWorld 2023 - Multi-cloud App Dev for Java Devs with Microsoft Azu...Juarez Junior
 
GeeCon Prague 2023 - Unleash the power of your applications with Micronaut®, ...
GeeCon Prague 2023 - Unleash the power of your applications with Micronaut®, ...GeeCon Prague 2023 - Unleash the power of your applications with Micronaut®, ...
GeeCon Prague 2023 - Unleash the power of your applications with Micronaut®, ...Juarez Junior
 
SevillaJUG - Unleash the power of your applications with Micronaut® ,GraalVM...
SevillaJUG - Unleash the power of your applications with Micronaut®  ,GraalVM...SevillaJUG - Unleash the power of your applications with Micronaut®  ,GraalVM...
SevillaJUG - Unleash the power of your applications with Micronaut® ,GraalVM...Juarez Junior
 
SKILup Days Container Orchestration - Kubernetes Operators for Databases
SKILup Days Container Orchestration - Kubernetes Operators for DatabasesSKILup Days Container Orchestration - Kubernetes Operators for Databases
SKILup Days Container Orchestration - Kubernetes Operators for DatabasesJuarez Junior
 
DTU Global Azure 2023 Bootcamp - Multi-cloud App Dev for Java Developers with...
DTU Global Azure 2023 Bootcamp - Multi-cloud App Dev for Java Developers with...DTU Global Azure 2023 Bootcamp - Multi-cloud App Dev for Java Developers with...
DTU Global Azure 2023 Bootcamp - Multi-cloud App Dev for Java Developers with...Juarez Junior
 
JCON OpenBlend Slovenia 2023 - A High-Speed Data Ingestion Service in Java Us...
JCON OpenBlend Slovenia 2023 - A High-Speed Data Ingestion Service in Java Us...JCON OpenBlend Slovenia 2023 - A High-Speed Data Ingestion Service in Java Us...
JCON OpenBlend Slovenia 2023 - A High-Speed Data Ingestion Service in Java Us...Juarez Junior
 
DeveloperWeekEnterprise2023 - Introduction to Kubernetes Operators for Databases
DeveloperWeekEnterprise2023 - Introduction to Kubernetes Operators for DatabasesDeveloperWeekEnterprise2023 - Introduction to Kubernetes Operators for Databases
DeveloperWeekEnterprise2023 - Introduction to Kubernetes Operators for DatabasesJuarez Junior
 
DevConf.cz - Introduction to Kubernetes Operators for Databases
DevConf.cz - Introduction to Kubernetes Operators for DatabasesDevConf.cz - Introduction to Kubernetes Operators for Databases
DevConf.cz - Introduction to Kubernetes Operators for DatabasesJuarez Junior
 
[pt-BR] - Cloud Conference Day - Agilidade para disponibilização de aplicaçõe...
[pt-BR] - Cloud Conference Day - Agilidade para disponibilização de aplicaçõe...[pt-BR] - Cloud Conference Day - Agilidade para disponibilização de aplicaçõe...
[pt-BR] - Cloud Conference Day - Agilidade para disponibilização de aplicaçõe...Juarez Junior
 
Microsoft Azure - GAA and Irish Tech Society Hackathon
Microsoft Azure - GAA and Irish Tech Society HackathonMicrosoft Azure - GAA and Irish Tech Society Hackathon
Microsoft Azure - GAA and Irish Tech Society HackathonJuarez Junior
 
JSNation.com - Azure Static Web Apps (SWA) with Azure DevOps
JSNation.com - Azure Static Web Apps (SWA) with Azure DevOpsJSNation.com - Azure Static Web Apps (SWA) with Azure DevOps
JSNation.com - Azure Static Web Apps (SWA) with Azure DevOpsJuarez Junior
 
Azure DevOps with DV and GitHub
Azure DevOps with DV and GitHubAzure DevOps with DV and GitHub
Azure DevOps with DV and GitHubJuarez Junior
 

More from Juarez Junior (14)

Oracle CloudWorld 2023 - How to hook up Telegram with Spring Boot and ADB
Oracle CloudWorld 2023 - How to hook up Telegram with Spring Boot and ADBOracle CloudWorld 2023 - How to hook up Telegram with Spring Boot and ADB
Oracle CloudWorld 2023 - How to hook up Telegram with Spring Boot and ADB
 
Oracle CloudWorld 2023 - A Practical Guide to Implementing DevOps with IaC fo...
Oracle CloudWorld 2023 - A Practical Guide to Implementing DevOps with IaC fo...Oracle CloudWorld 2023 - A Practical Guide to Implementing DevOps with IaC fo...
Oracle CloudWorld 2023 - A Practical Guide to Implementing DevOps with IaC fo...
 
Oracle CloudWorld 2023 - Multi-cloud App Dev for Java Devs with Microsoft Azu...
Oracle CloudWorld 2023 - Multi-cloud App Dev for Java Devs with Microsoft Azu...Oracle CloudWorld 2023 - Multi-cloud App Dev for Java Devs with Microsoft Azu...
Oracle CloudWorld 2023 - Multi-cloud App Dev for Java Devs with Microsoft Azu...
 
GeeCon Prague 2023 - Unleash the power of your applications with Micronaut®, ...
GeeCon Prague 2023 - Unleash the power of your applications with Micronaut®, ...GeeCon Prague 2023 - Unleash the power of your applications with Micronaut®, ...
GeeCon Prague 2023 - Unleash the power of your applications with Micronaut®, ...
 
SevillaJUG - Unleash the power of your applications with Micronaut® ,GraalVM...
SevillaJUG - Unleash the power of your applications with Micronaut®  ,GraalVM...SevillaJUG - Unleash the power of your applications with Micronaut®  ,GraalVM...
SevillaJUG - Unleash the power of your applications with Micronaut® ,GraalVM...
 
SKILup Days Container Orchestration - Kubernetes Operators for Databases
SKILup Days Container Orchestration - Kubernetes Operators for DatabasesSKILup Days Container Orchestration - Kubernetes Operators for Databases
SKILup Days Container Orchestration - Kubernetes Operators for Databases
 
DTU Global Azure 2023 Bootcamp - Multi-cloud App Dev for Java Developers with...
DTU Global Azure 2023 Bootcamp - Multi-cloud App Dev for Java Developers with...DTU Global Azure 2023 Bootcamp - Multi-cloud App Dev for Java Developers with...
DTU Global Azure 2023 Bootcamp - Multi-cloud App Dev for Java Developers with...
 
JCON OpenBlend Slovenia 2023 - A High-Speed Data Ingestion Service in Java Us...
JCON OpenBlend Slovenia 2023 - A High-Speed Data Ingestion Service in Java Us...JCON OpenBlend Slovenia 2023 - A High-Speed Data Ingestion Service in Java Us...
JCON OpenBlend Slovenia 2023 - A High-Speed Data Ingestion Service in Java Us...
 
DeveloperWeekEnterprise2023 - Introduction to Kubernetes Operators for Databases
DeveloperWeekEnterprise2023 - Introduction to Kubernetes Operators for DatabasesDeveloperWeekEnterprise2023 - Introduction to Kubernetes Operators for Databases
DeveloperWeekEnterprise2023 - Introduction to Kubernetes Operators for Databases
 
DevConf.cz - Introduction to Kubernetes Operators for Databases
DevConf.cz - Introduction to Kubernetes Operators for DatabasesDevConf.cz - Introduction to Kubernetes Operators for Databases
DevConf.cz - Introduction to Kubernetes Operators for Databases
 
[pt-BR] - Cloud Conference Day - Agilidade para disponibilização de aplicaçõe...
[pt-BR] - Cloud Conference Day - Agilidade para disponibilização de aplicaçõe...[pt-BR] - Cloud Conference Day - Agilidade para disponibilização de aplicaçõe...
[pt-BR] - Cloud Conference Day - Agilidade para disponibilização de aplicaçõe...
 
Microsoft Azure - GAA and Irish Tech Society Hackathon
Microsoft Azure - GAA and Irish Tech Society HackathonMicrosoft Azure - GAA and Irish Tech Society Hackathon
Microsoft Azure - GAA and Irish Tech Society Hackathon
 
JSNation.com - Azure Static Web Apps (SWA) with Azure DevOps
JSNation.com - Azure Static Web Apps (SWA) with Azure DevOpsJSNation.com - Azure Static Web Apps (SWA) with Azure DevOps
JSNation.com - Azure Static Web Apps (SWA) with Azure DevOps
 
Azure DevOps with DV and GitHub
Azure DevOps with DV and GitHubAzure DevOps with DV and GitHub
Azure DevOps with DV and GitHub
 

Recently uploaded

Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 

Recently uploaded (20)

Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 

jPrime 2023 - Revolutionize Java DB AppDev with Reactive Streams and Virtual Threads

  • 1. Revolutionize Java Database App Development with Reactive Streams and Virtual Threads jPrime 2023 Juarez Barbosa Junior @juarezjunior Sr. Principal Java Developer Evangelist ORACLE Copyright © 2023, Oracle and/or its affiliates
  • 2. Agenda • Java App Dev with Oracle Database • Support for the Latest Java Versions • Overview of Oracle DB Access with Java • Oracle JDBC – Sync and Async • Classic Java Platform Threads • Project Loom – Virtual Threads • Virtual Threads - JEPs 425, 436, 444 • Demo # 1: Virtual vs Platform Threads • Reactive JDBC - Synchronous vs Asynchronous JDBC • Reactive Streams Ingestion (RSI) • Demo # 2: Reactive Streams Ingestion (RSI) • From Sync to Reactive JDBC: Oracle R2DBC • Demo # 3: Oracle R2DBC with Project Reactor • Live Labs/Free Oracle Cloud Account/Oracle ACE Program Copyright © 2023, Oracle and/or its affiliates
  • 3. Copyright © 2023, Oracle and/or its affiliates Java App Dev with Oracle Database
  • 4. Copyright © 2023, Oracle and/or its affiliates Support for the Latest Java Versions • Java 11 - native support, compiled with it • Java 17 - certified • JDBC Standards - 4.2 and 4.3 • GraalVM - native image instrumentation • Reactive Streams - Java Flow API support • Project Loom - Virtual Threads support • Data access is critical in mission-critical apps
  • 5. Copyright © 2023, Oracle and/or its affiliates Overview of Oracle DB Access with Java User Java Code JDBC Reactive Extension Standard JDBC API R2DBC + 3rd party Reactive Streams Libraries Async call with non-blocking backpressure operators (map, reduce, filters), concurrency modeling, monitoring, tracing Implements Java SE reactive stream interface (Flow) Full Reactive Streams Sync/blocking JDBC calls Java Business Logic User Java code Oracle Database Oracle JDBC driver VTs/lightweight JDBC calls
  • 6. Copyright © 2022, Oracle and/or its affiliates Oracle JDBC – Async and Sync ⚫ Project Loom/Virtual Threads − Synchronous database access with lightweight threads − Standard JDBC + Virtual Threads − Client application call stack may use conventional (synchronous) code − Libraries must be compatible with Virtual Threads − Oracle instrumented the Oracle JDBC 21c driver to support Virtual Threads ⚫ Reactive Programming − Asynchronous database access with non-blocking network I/O − Oracle Reactive Streams Ingestion + Oracle R2DBC + Oracle JDBC Reactive Extensions − Application call stack must be fully asynchronous − Libraries are available: Reactor, RxJava, Akka, Vert.x
  • 7. Copyright © 2023, Oracle and/or its affiliates Classic Java Platform Threads ⚫ Database access with blocking threads ⚫ A JDBC call blocks a thread for 100’s of milliseconds (thread-per-request style) ⚫ Thread count increases linearly with the number of JDBC calls ⚫ Performance degrades as the number of threads increases ⚫ 1 MB of stack memory per thread ⚫ Scheduling many platform threads is expensive ⚫ Preemptive scheduling vs time-slicing
  • 8. Copyright © 2022, Oracle and/or its affiliates Virtual Threads - JEPs 425, 436, 444 ⚫ Virtual Threads – JEPs (JDK Enhancement Proposals) ⚫ Lightweight threads that dramatically reduce the effort of writing, maintaining, and observing high-throughput concurrent applications ⚫ Enable applications written in the simple thread-per-request style to scale with near- optimal hardware utilization ⚫ Enable easy troubleshooting, debugging, and profiling of virtual threads with existing JDK tools ⚫ Do not remove the traditional implementation of threads ⚫ Do not alter the basic concurrency model of Java ⚫ Enable existing code that uses Java threads (java.lang.Thread, etc) to adopt virtual threads with minimal change
  • 9. Copyright © 2023, Oracle and/or its affiliates Virtual Threads - JEPs 425, 436, 444 ⚫ java.lang.Thread ⚫ final Boolean - isVirtual() ⚫ static Thread.Builder.OfVirtual - ofVirtual() ⚫ static Thread.Builder.OfPlatform - ofPlatform() ⚫ static Thread - startVirtualThread(Runnable task) ⚫ java.util.concurrent.Executors ⚫ static ExecutorService - newVirtualThreadPerTaskExecutor()
  • 10. Copyright © 2022, Oracle and/or its affiliates Demo # 1: Virtual vs Platform Threads ⚫ Virtual Threads versus Platform Threads ⚫ JEP 425 Virtual Threads (Preview) ⚫ JEP 436 (Second Preview) ⚫ JEP 444 (Target -> JDK 21) ⚫ Runs on Java 19, 20, 21 ⚫ javac --release 19 --enable-preview ⚫ java --enable-preview ⚫ Oracle JDBC Driver 21c instrumented to support Virtual Threads ⚫ Verifiable comparison of OS/HW resources consumption (Platform Threads x Virtual Threads)
  • 11. Copyright © 2023, Oracle and/or its affiliates Reactive JDBC - Sync vs Async JDBC Setup Blocking Handle Result Setup Non-Blocking Handle Result Synchronous JDBC Setup Blocking Handle Result Setup Non-Blocking Handle Result Setup Non-Blocking Handle Result Reactive JDBC Database Setup Blocking Handle Result Database
  • 12. Copyright © 2022, Oracle and/or its affiliates Reactive Streams Ingestion (RSI) ⚫ Java Library for Reactive Streams Ingestion ⚫ Streaming capability: Ingest data in an unblocking, and reactive way from a large group of clients ⚫ Group records through RAC (Real App Clusters), and Shard affinity using native UCP (Universal Connection Pool) ⚫ Optimize CPU allocation while decoupling record Processing from I/O ⚫ Fastest insert method for the Oracle Database through Direct Path Insert, bypassing SQL and writing directly into the DB files
  • 13. Copyright © 2023, Oracle and/or its affiliates Demo # 2: Reactive Streams Ingestion (RSI) Container Pipelines, Jenkins, etc. Build Test Push Push Docker images to Registry Cloud Infrastructur e Registry Container Engine for Kubernetes Pull images from Registry Deploy images to production Kubernetes worker nodes Containers running microservices deployed over Kubernetes ORACLE CLOUD INFRASTRUCTURE ATP, ADW, ATP-D, AFDW-D Memoptimized Rowstore RSI Runtime: Non- blocking, optimized library for streaming data through Direct Path, Shard & RAC/FAN support. HTTP / REST Engine over Helidon Define build for CI/CD toolchain gRPC / AMQP / MQTT Engines Microservices Files / Logs IoT Devices / Apps cv MQTT gRPC AMQP HTTP / REST JDBC Direct Path INSERT Record Streaming over multiple protocols.
  • 14. Copyright © 2022, Oracle and/or its affiliates Oracle R2DBC ⚫ Oracle Reactive Relational Database Connectivity (R2DBC) ⚫ Oracle R2DBC Driver is a Java library that supports reactive Programming with Oracle Database ⚫ It implements the R2DBC Service Provider Interface (SPI) as specified by the Reactive Relational Database Connectivity (R2DBC) ⚫ The R2DBC SPI exposes Reactive Streams as an abstraction for Remote database operations ⚫ The sample code uses Project Reactor. It could use RxJava, Akka, or any RS library ⚫ Runs on Java 11+
  • 15. Copyright © 2023, Oracle and/or its affiliates From Sync to Reactive JDBC: Oracle R2DBC static String queryJdbc(java.sql.Connection connection) throws SQLException { try (java.sql.Statement statement = connection.createStatement()) { ResultSet resultSet = statement.executeQuery("SELECT * FROM CUSTOMERS"); if (resultSet.next()) return resultSet.getString(1); else throw new NoSuchElementException("Query returned zero rows"); } } static Publisher<String> queryR2dbc(io.r2dbc.spi.Connection connection) { return Flux.from(connection.createStatement( "SELECT * FROM CUSTOMERS") .execute()) .flatMap(result -> result.map(row -> row.get(0, String.class))) .switchIfEmpty(Flux.error( new NoSuchElementException("Query returned zero rows"))); }
  • 16. Virtual Threads or Reactive? • Oracle JDBC supports both! • Want Virtual Threads? • Oracle JDBC has been “Virtual Thread Compatible” since 21.1.0.0 • Want Reactive? • Oracle R2DBC 1.0.0 is available now • Consume Flow interfaces directly from Oracle JDBC’s Reactive Extensions Copyright © 2023, Oracle and/or its affiliates
  • 17. Virtual Threads or Reactive? • Benefits of Virtual Threads: • Easier to read and write • Easier to debug • Integration with JDK tools • Do not alter the basic concurrency model of Java • Limitations of Virtual Threads: • Some libraries are not compatible • Still not in GA –> JDK 21 • JEP 425: Virtual Threads (Preview) • JEP 436: Virtual Threads (Second Preview) • JEP 444: Virtual Threads Copyright © 2023, Oracle and/or its affiliates Benefits of Reactive: • Reactive Libraries (Reactor, RxJava, Akka, Vert.x) • Stream-like API with a functional style • Low-level concurrency is handled for you (locks, atomics, queues). Limitations of Reactive: • Steep learning curve • Harder to read and write • Harder to debug
  • 18. Copyright © 2023, Oracle and/or its affiliates References • Project Loom / Virtual Threads • Loom - https://openjdk.org/projects/loom/ • JEP 444 Virtual Threads (Targeted) - https://openjdk.org/jeps/444 • Introduction to Oracle JDBC 21c Driver Support for Virtual Threads - https://bit.ly/3UlNJWP • Reactive Streams Ingestion Library • Getting Started with the Java library for Reactive Streams Ingestion (RSI) - https://bit.ly/3rEiRnC • High-throughput stream processing with the Java Library for Reactive Streams Ingestion (RSI), Virtual Threads, and the Oracle ATP Database - https://bit.ly/3rATCTd • RSI - https://docs.oracle.com/en/database/oracle/ • R2DBC • Oracle R2DBC Driver – https://github.com/oracle/oracle-r2dbc • Develop Java applications with Oracle Database • JDBC – https://www.oracle.com/database/technologies/appdev/jdbc.html
  • 19. Oracle Database 23c Oracle Database 23c Free – Developer Edition available for download now • Oracle Database 23c accelerates Oracle’s mission to make it simple to develop and run all data-driven apps • Provides developers easy early access to 23c app dev features • Limited database size, memory, CPU threads (same limits as Express Edition) Free Developer Release http://oracle.com/23cFree http://oracle.com/23cFree
  • 20. Oracle LiveLabs Showcasing how Oracle’s solutions can solve your business problems 500+ free workshops, available or in development 3.5 million people have already visited LiveLabs developer.oracle.com/livelabs learn something new …at your pace! 600+ events run using LiveLabs workshops
  • 21. 3 membership tiers Connect: @oracleace facebook.com/OracleACEs aceprogram_ww@oracle.com 500+ technical experts & community leaders helping peers globally The Oracle ACE Program recognizes & rewards individuals for their technical & community contributions to the Oracle community Nominate yourself or a candidate: ace.oracle.com/nominate Learn more - ace.oracle.com blogs.oracle.com/ace
  • 22. Create your FREE Cloud Account • Go to https://signup.cloud.oracle.com/ Copyright © 2023, Oracle and/or its affiliates
  • 23. About me • Juarez Barbosa Junior - @juarezjunior • Senior Principal Java Developer Evangelist • 27 years of experience • SW Engineering, Developer Relations • Microsoft, Oracle, IBM, Nokia, Unisys, Accenture, and a few startups • Microsoft Azure Developer Relations Lead • IBM Watson Tech Evangelist & Cloud Rockstar • IBM Mobile Tech Evangelist & Global Thought Leader • Nokia Developers Global Champion • Lead Software/DevOps Architect • Expertise • Java, Cloud, DevOps, Cloud-native, Blockchain Copyright © 2023, Oracle and/or its affiliates
  • 24. Thank you! 24 Copyright © 2023, Oracle and/or its affiliates | Confidential: Internal