SlideShare a Scribd company logo
Revolutionize Java Database App
Development with Reactive Streams and
Virtual Threads
Juarez Barbosa Junior - @juarezjunior
• Sr. 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, Blockchain
About me
Java App Dev with Oracle Database
• Language Comprehensive Programming Language and Framework Support
• Mission Critical Simple Mission Critical Application Development
• Cloud-native Seamless cloud-native application development
• IDE Support Plugins for popular IDEs with Oracle Database and OCI support
Oracle Database
Summary 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
⚫ Reactive Programming
− Asynchronous database access with non-blocking network I/O
− Oracle R2DBC + Oracle JDBC Reactive Extensions + Oracle Reactive Streams Ingestion
− Application call stack must be fully asynchronous
− Libraries are here to support it: Reactor, RxJava, Akka, Vert.x
⚫ 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
Two Solutions : Oracle JDBC Supports Both
⚫ 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 on a single CPU is expensive
⚫ Reactive Programming
⚫ Multiple threads are required when handling an async request
⚫ Async calls are executed in different threads -> hard to debug them
⚫ Paradigm shift requires upskilling efforts
⚫ Hard to maintain
The Problem: Classic Java Platform Threads
The Solution: Virtual Threads
⚫ JEP 425: Virtual Threads (JDK 19 - Preview API)
⚫ Lightweight threads that dramatically reduce the effort of writing, maintaining, and observing
high-throughput concurrent applications
⚫ VTs enable applications written in the simple thread-per-request style to scale with near-
optimal hardware utilization
⚫ VTs enable existing code that uses the java.lang.Thread API to adopt virtual threads with
minimal change
⚫ VTs enable easy troubleshooting, debugging, and profiling of virtual threads with existing JDK
tools
⚫ VTs do not remove the traditional implementation of threads
⚫ VTs do not alter the basic concurrency model of Java
⚫ Demo #1: Virtual Threads
− Oracle JDBC Driver 21c instrumented to support Virtual Threads
− API is Oracle JDBC with the Java SE library (Executor, ThreadFactory)
− JEP 425 Virtual Threads (Project Loom – Preview API)
− Runs on Java 19
Demos
Reactive JDBC - Synchronous vs Asynchronous 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
From Synchronous to Reactive JDBC: Query
static String queryJdbc(java.sql.Connection connection) throws
SQLException {
try (java.sql.Statement statement = connection.createStatement()) {
ResultSet resultSet =
statement.executeQuery("SELECT 'Hello, JDBC!' FROM sys.dual");
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 'Hello, R2DBC!' FROM sys.dual")
.execute())
.flatMap(result ->
result.map(row -> row.get(0, String.class)))
.switchIfEmpty(Flux.error(
new NoSuchElementException("Query returned zero rows")));
}
⚫ Demo #1: Reactive JDBC
− API is Oracle R2DBC with a reactive streams library
− Demo uses Project Reactor. Could use RxJava, Akka, or any RS library
− Runs on Java 11+
Demos
References
• R2DBC
• Oracle R2DBC Driver – https://github.com/oracle/oracle-r2dbc
• JDK 19 / Project Loom
• JDK 19 - https://openjdk.org/projects/jdk/19/
• Loom - https://openjdk.org/projects/loom/
• JEP 425 Virtual Threads (Preview) - https://bugs.openjdk.org/browse/JDK-8277131
• Develop Java applications with Oracle Database
• JDBC – https://www.oracle.com/database/technologies/appdev/jdbc.html
• Reactive Streams Ingestion Library
• RSI – https://docs.oracle.com/en/database/oracle/oracle-
database/21/jarsi/oracle/rsi/package-summary.html
• https://medium.com/oracledevs/getting-started-with-the-java-library-for-reactive-streams-
ingestion-rsi-afbc808e6e24
#MeleeNum
Thank you!!!
Reactive Streams Ingestion Library
Java Program
Reactive Streams Ingestion Library
Direct Path Insert
Thread Scheduling
Record Grouping and Routing
UCP Pooling and
Routing (Shard &
Rac)
1
2
3
4
⚫ Demo #3: Reactive Streams Ingestion Library
− API is Oracle Reactive Streams Ingestion Library
− Leverages Oracle Direct Path Insert
− Optimized CPU allocation
− Record Grouping and Routing
Demos
Poll
Pick one or more options that may describe your situation:
• Not concerned by thread counts/throughput
• Not using reactive, waiting for Project Loom (Virtual Threads)
• Interested in, or already using a reactive framework (Reactor, RxJava)
• Interested in, or already using R2DBC
• Interested in, or already using Oracle JDBC Reactive Extensions
• Interested in, or already using Oracle Reactive Streams Ingestion (RSI)

More Related Content

PDF
TDC Connections 2023 - Revolutionize Java DB AppDev with Reactive Streams and...
PDF
DeveloperWeek Europe 2023 - Revolutionize Java DB AppDev with Reactive Stream...
PDF
Andersen_Revolutionize Java DB AppDev with Reactive Streams and Virtual Threa...
PDF
BarcelonaJUG - Revolutionize Java Database Application Development with React...
PDF
jPrime 2023 - Revolutionize Java DB AppDev with Reactive Streams and Virtual ...
PDF
Porto Tech Hub Conference 2023 - Revolutionize Java DB AppDev with Reactive S...
PDF
DWX23 - Revolutionize Java DB AppDev with Reactive Streams and Virtual Threads
PDF
CloudLand - Revolutionize Java DB AppDev with Reactive Streams and Virtual Th...
TDC Connections 2023 - Revolutionize Java DB AppDev with Reactive Streams and...
DeveloperWeek Europe 2023 - Revolutionize Java DB AppDev with Reactive Stream...
Andersen_Revolutionize Java DB AppDev with Reactive Streams and Virtual Threa...
BarcelonaJUG - Revolutionize Java Database Application Development with React...
jPrime 2023 - Revolutionize Java DB AppDev with Reactive Streams and Virtual ...
Porto Tech Hub Conference 2023 - Revolutionize Java DB AppDev with Reactive S...
DWX23 - Revolutionize Java DB AppDev with Reactive Streams and Virtual Threads
CloudLand - Revolutionize Java DB AppDev with Reactive Streams and Virtual Th...

Similar to Melee Numerique 2022 - Revolutionize Java DB App Dev with Reactive Streams and Virtual Threads (20)

PDF
Cloud Conference Day - Revolutionize Java Database App Development with React...
PDF
CloudTalks - Revolutionize Java DB AppDev with Reactive Streams and Virtual T...
PDF
BarcelonaJUG - A High-Speed Data Ingestion Service in Java Using MQTT, AMQP, ...
PDF
Cloud Conference Day - A High-Speed Data Ingestion Service in Java Using MQTT...
PDF
AI Industrial Summit - SOFIA, BULGARIA - A High-Speed Data Ingestion Microser...
PDF
DWX23 - A High-Speed Data Ingestion Service in Java Using MQTT, AMQP, and STO...
PDF
CloudLand - A High-Speed Data Ingestion Service in Java Using MQTT, AMQP, and...
PDF
DeveloperWeek Latin America 2023 - A High-Speed Data Ingestion Service in Jav...
PDF
The Making of the Oracle R2DBC Driver and How to Take Your Code from Synchron...
PPTX
R2DBC Reactive Relational Database Connectivity
PDF
Oracle CloudWorld 2023 - A High-Speed Data Ingestion Service in Java Using MQ...
PDF
ADBA (Asynchronous Database Access)
PDF
JDBC Next: A New Asynchronous API for Connecting to a Database
PDF
Full Steam Ahead, R2DBC!
PDF
Quarkus Club_Java Virtual Threads & Pipelined Database Operations
PDF
JCON OpenBlend Slovenia 2023 - A High-Speed Data Ingestion Service in Java Us...
PPT
JDBC Connectivity Model
PDF
Reactive Microservice And Spring5
PDF
Spring 5 Project Reactor
Cloud Conference Day - Revolutionize Java Database App Development with React...
CloudTalks - Revolutionize Java DB AppDev with Reactive Streams and Virtual T...
BarcelonaJUG - A High-Speed Data Ingestion Service in Java Using MQTT, AMQP, ...
Cloud Conference Day - A High-Speed Data Ingestion Service in Java Using MQTT...
AI Industrial Summit - SOFIA, BULGARIA - A High-Speed Data Ingestion Microser...
DWX23 - A High-Speed Data Ingestion Service in Java Using MQTT, AMQP, and STO...
CloudLand - A High-Speed Data Ingestion Service in Java Using MQTT, AMQP, and...
DeveloperWeek Latin America 2023 - A High-Speed Data Ingestion Service in Jav...
The Making of the Oracle R2DBC Driver and How to Take Your Code from Synchron...
R2DBC Reactive Relational Database Connectivity
Oracle CloudWorld 2023 - A High-Speed Data Ingestion Service in Java Using MQ...
ADBA (Asynchronous Database Access)
JDBC Next: A New Asynchronous API for Connecting to a Database
Full Steam Ahead, R2DBC!
Quarkus Club_Java Virtual Threads & Pipelined Database Operations
JCON OpenBlend Slovenia 2023 - A High-Speed Data Ingestion Service in Java Us...
JDBC Connectivity Model
Reactive Microservice And Spring5
Spring 5 Project Reactor
Ad

More from Juarez Junior (20)

PDF
WeAreDevelopers Berlin - Blazingly Fast GenAI App Development With Java and S...
PDF
WeAreDevelopers Berlin - LangChain4J - A Guide for Impatient Developers
PDF
Build Stuff Lithuania - Blazingly Fast GenAI App Development With Java and Sp...
PDF
DUBJUG-Simplifying Data Access with Jakarta Data for Domain-Driven Design
PDF
Cloud Lunch and Learn -Microsoft Semantic Kernel for Java
PDF
Compass AI Budapest -The Trinity in GenAI - Spring AI, LangChain4J and OpenAI
PDF
GSAS - Global Software Architecture Summit - GenAI-Architectural-Blueprints
PDF
BaselOne_Langchain4J - A Guide for Impatient Developers
PDF
DeveloperWeek USA - A Solid Foundation for GenAI Apps - Exploring Architectur...
PDF
I Love Tech Romania - Blazingly Fast GenAI App Development With Java and Spri...
PDF
I Love Tech Romania - The Trinity in GenAI - Spring AI, LangChain4J and OpenAI
PDF
DUBJUG_Blazingly Fast GenAI App Development With Java and Spring AI.pdf
PDF
DUBJUG_Creating GenAI Apps in Java with SD4J and the ONNX Runtime
PDF
I Love Tech Romania - A High-Speed Data Ingestion Microservice in Java Using ...
PDF
DevTalks Cluj Romania - A Solid Foundation for GenAI Apps.pdf
PDF
Quarkus Club_Revolutionize Java Database App Development with Reactive Stream...
PDF
TDC - The Developers Conference - The Trinity in GenAI - Spring AI, LangChain...
PDF
TDC - The Developers Conference - Creating GenAI Apps in Java with SD4J and t...
PDF
TDC - The Developers Conference - An Introduction to Machine Learning in Java...
PDF
SouJava - Blazingly Fast GenAI App Development With Java and Spring AI
WeAreDevelopers Berlin - Blazingly Fast GenAI App Development With Java and S...
WeAreDevelopers Berlin - LangChain4J - A Guide for Impatient Developers
Build Stuff Lithuania - Blazingly Fast GenAI App Development With Java and Sp...
DUBJUG-Simplifying Data Access with Jakarta Data for Domain-Driven Design
Cloud Lunch and Learn -Microsoft Semantic Kernel for Java
Compass AI Budapest -The Trinity in GenAI - Spring AI, LangChain4J and OpenAI
GSAS - Global Software Architecture Summit - GenAI-Architectural-Blueprints
BaselOne_Langchain4J - A Guide for Impatient Developers
DeveloperWeek USA - A Solid Foundation for GenAI Apps - Exploring Architectur...
I Love Tech Romania - Blazingly Fast GenAI App Development With Java and Spri...
I Love Tech Romania - The Trinity in GenAI - Spring AI, LangChain4J and OpenAI
DUBJUG_Blazingly Fast GenAI App Development With Java and Spring AI.pdf
DUBJUG_Creating GenAI Apps in Java with SD4J and the ONNX Runtime
I Love Tech Romania - A High-Speed Data Ingestion Microservice in Java Using ...
DevTalks Cluj Romania - A Solid Foundation for GenAI Apps.pdf
Quarkus Club_Revolutionize Java Database App Development with Reactive Stream...
TDC - The Developers Conference - The Trinity in GenAI - Spring AI, LangChain...
TDC - The Developers Conference - Creating GenAI Apps in Java with SD4J and t...
TDC - The Developers Conference - An Introduction to Machine Learning in Java...
SouJava - Blazingly Fast GenAI App Development With Java and Spring AI
Ad

Recently uploaded (20)

PPTX
MYSQL Presentation for SQL database connectivity
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
cuic standard and advanced reporting.pdf
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
Cloud computing and distributed systems.
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
KodekX | Application Modernization Development
PDF
Approach and Philosophy of On baking technology
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
Programs and apps: productivity, graphics, security and other tools
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PPTX
Big Data Technologies - Introduction.pptx
MYSQL Presentation for SQL database connectivity
Encapsulation_ Review paper, used for researhc scholars
MIND Revenue Release Quarter 2 2025 Press Release
cuic standard and advanced reporting.pdf
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
The Rise and Fall of 3GPP – Time for a Sabbatical?
Reach Out and Touch Someone: Haptics and Empathic Computing
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Cloud computing and distributed systems.
Per capita expenditure prediction using model stacking based on satellite ima...
KodekX | Application Modernization Development
Approach and Philosophy of On baking technology
Chapter 3 Spatial Domain Image Processing.pdf
20250228 LYD VKU AI Blended-Learning.pptx
Programs and apps: productivity, graphics, security and other tools
The AUB Centre for AI in Media Proposal.docx
Understanding_Digital_Forensics_Presentation.pptx
Big Data Technologies - Introduction.pptx

Melee Numerique 2022 - Revolutionize Java DB App Dev with Reactive Streams and Virtual Threads

  • 1. Revolutionize Java Database App Development with Reactive Streams and Virtual Threads
  • 2. Juarez Barbosa Junior - @juarezjunior • Sr. 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, Blockchain About me
  • 3. Java App Dev with Oracle Database • Language Comprehensive Programming Language and Framework Support • Mission Critical Simple Mission Critical Application Development • Cloud-native Seamless cloud-native application development • IDE Support Plugins for popular IDEs with Oracle Database and OCI support Oracle Database
  • 4. Summary 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
  • 5. ⚫ Reactive Programming − Asynchronous database access with non-blocking network I/O − Oracle R2DBC + Oracle JDBC Reactive Extensions + Oracle Reactive Streams Ingestion − Application call stack must be fully asynchronous − Libraries are here to support it: Reactor, RxJava, Akka, Vert.x ⚫ 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 Two Solutions : Oracle JDBC Supports Both
  • 6. ⚫ 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 on a single CPU is expensive ⚫ Reactive Programming ⚫ Multiple threads are required when handling an async request ⚫ Async calls are executed in different threads -> hard to debug them ⚫ Paradigm shift requires upskilling efforts ⚫ Hard to maintain The Problem: Classic Java Platform Threads
  • 7. The Solution: Virtual Threads ⚫ JEP 425: Virtual Threads (JDK 19 - Preview API) ⚫ Lightweight threads that dramatically reduce the effort of writing, maintaining, and observing high-throughput concurrent applications ⚫ VTs enable applications written in the simple thread-per-request style to scale with near- optimal hardware utilization ⚫ VTs enable existing code that uses the java.lang.Thread API to adopt virtual threads with minimal change ⚫ VTs enable easy troubleshooting, debugging, and profiling of virtual threads with existing JDK tools ⚫ VTs do not remove the traditional implementation of threads ⚫ VTs do not alter the basic concurrency model of Java
  • 8. ⚫ Demo #1: Virtual Threads − Oracle JDBC Driver 21c instrumented to support Virtual Threads − API is Oracle JDBC with the Java SE library (Executor, ThreadFactory) − JEP 425 Virtual Threads (Project Loom – Preview API) − Runs on Java 19 Demos
  • 9. Reactive JDBC - Synchronous vs Asynchronous 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
  • 10. From Synchronous to Reactive JDBC: Query static String queryJdbc(java.sql.Connection connection) throws SQLException { try (java.sql.Statement statement = connection.createStatement()) { ResultSet resultSet = statement.executeQuery("SELECT 'Hello, JDBC!' FROM sys.dual"); 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 'Hello, R2DBC!' FROM sys.dual") .execute()) .flatMap(result -> result.map(row -> row.get(0, String.class))) .switchIfEmpty(Flux.error( new NoSuchElementException("Query returned zero rows"))); }
  • 11. ⚫ Demo #1: Reactive JDBC − API is Oracle R2DBC with a reactive streams library − Demo uses Project Reactor. Could use RxJava, Akka, or any RS library − Runs on Java 11+ Demos
  • 12. References • R2DBC • Oracle R2DBC Driver – https://github.com/oracle/oracle-r2dbc • JDK 19 / Project Loom • JDK 19 - https://openjdk.org/projects/jdk/19/ • Loom - https://openjdk.org/projects/loom/ • JEP 425 Virtual Threads (Preview) - https://bugs.openjdk.org/browse/JDK-8277131 • Develop Java applications with Oracle Database • JDBC – https://www.oracle.com/database/technologies/appdev/jdbc.html • Reactive Streams Ingestion Library • RSI – https://docs.oracle.com/en/database/oracle/oracle- database/21/jarsi/oracle/rsi/package-summary.html • https://medium.com/oracledevs/getting-started-with-the-java-library-for-reactive-streams- ingestion-rsi-afbc808e6e24
  • 14. Reactive Streams Ingestion Library Java Program Reactive Streams Ingestion Library Direct Path Insert Thread Scheduling Record Grouping and Routing UCP Pooling and Routing (Shard & Rac) 1 2 3 4
  • 15. ⚫ Demo #3: Reactive Streams Ingestion Library − API is Oracle Reactive Streams Ingestion Library − Leverages Oracle Direct Path Insert − Optimized CPU allocation − Record Grouping and Routing Demos
  • 16. Poll Pick one or more options that may describe your situation: • Not concerned by thread counts/throughput • Not using reactive, waiting for Project Loom (Virtual Threads) • Interested in, or already using a reactive framework (Reactor, RxJava) • Interested in, or already using R2DBC • Interested in, or already using Oracle JDBC Reactive Extensions • Interested in, or already using Oracle Reactive Streams Ingestion (RSI)