SlideShare a Scribd company logo
Revolutionize Java Database App
Development with Reactive Streams and
Virtual Threads
CloudLand 2023
Juarez Barbosa Junior @juarezjunior
Sr. Principal Java Developer Evangelist
ORACLE
Copyright Ā© 2023, Oracle and/or its affiliates
About me
• Juarez Barbosa Junior - @juarezjunior
• Senior Principal Java Developer Evangelist
• 27 years of experience in IT
• 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
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 in IT
• 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!
25
Copyright Ā© 2023, Oracle and/or its affiliates | Confidential: Internal

More Related Content

PDF
Cloud Conference Day - Revolutionize Java Database App Development with React...
Juarez Junior
Ā 
PDF
CloudTalks - Revolutionize Java DB AppDev with Reactive Streams and Virtual T...
Juarez Junior
Ā 
PDF
BarcelonaJUG - Revolutionize Java Database Application Development with React...
Juarez Junior
Ā 
PDF
Porto Tech Hub Conference 2023 - Revolutionize Java DB AppDev with Reactive S...
Juarez Junior
Ā 
PDF
AI Industrial Summit - SOFIA, BULGARIA - A High-Speed Data Ingestion Microser...
Juarez Junior
Ā 
PDF
Andersen_Revolutionize Java DB AppDev with Reactive Streams and Virtual Threa...
Juarez Junior
Ā 
PDF
CloudLand - A High-Speed Data Ingestion Service in Java Using MQTT, AMQP, and...
Juarez Junior
Ā 
PDF
DWX23 - A High-Speed Data Ingestion Service in Java Using MQTT, AMQP, and STO...
Juarez Junior
Ā 
Cloud Conference Day - Revolutionize Java Database App Development with React...
Juarez Junior
Ā 
CloudTalks - Revolutionize Java DB AppDev with Reactive Streams and Virtual T...
Juarez Junior
Ā 
BarcelonaJUG - Revolutionize Java Database Application Development with React...
Juarez Junior
Ā 
Porto Tech Hub Conference 2023 - Revolutionize Java DB AppDev with Reactive S...
Juarez Junior
Ā 
AI Industrial Summit - SOFIA, BULGARIA - A High-Speed Data Ingestion Microser...
Juarez Junior
Ā 
Andersen_Revolutionize Java DB AppDev with Reactive Streams and Virtual Threa...
Juarez Junior
Ā 
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...
Juarez Junior
Ā 

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

PDF
jPrime 2023 - Revolutionize Java DB AppDev with Reactive Streams and Virtual ...
Juarez Junior
Ā 
PDF
BarcelonaJUG - A High-Speed Data Ingestion Service in Java Using MQTT, AMQP, ...
Juarez Junior
Ā 
PDF
Cloud Conference Day - A High-Speed Data Ingestion Service in Java Using MQTT...
Juarez Junior
Ā 
PDF
DeveloperWeek Europe 2023 - Revolutionize Java DB AppDev with Reactive Stream...
Juarez Junior
Ā 
PDF
Oracle CloudWorld 2023 - A High-Speed Data Ingestion Service in Java Using MQ...
Juarez Junior
Ā 
PDF
TDC Connections 2023 - Revolutionize Java DB AppDev with Reactive Streams and...
Juarez Junior
Ā 
PDF
DeveloperWeek Latin America 2023 - A High-Speed Data Ingestion Service in Jav...
Juarez Junior
Ā 
PDF
Quarkus Club_Java Virtual Threads & Pipelined Database Operations
Juarez Junior
Ā 
PDF
TDC Connections 2023 - A High-Speed Data Ingestion Service in Java Using MQTT...
Juarez Junior
Ā 
PDF
Melee Numerique 2022 - Revolutionize Java DB App Dev with Reactive Streams an...
Juarez Junior
Ā 
PPT
Rollin onj Rubyv3
Oracle
Ā 
PDF
JCON OpenBlend Slovenia 2023 - A High-Speed Data Ingestion Service in Java Us...
Juarez Junior
Ā 
PDF
What's New and Noteworthy on Oracle CAF 12.1.3
Bruno Borges
Ā 
PDF
ADBA (Asynchronous Database Access)
Logico
Ā 
PDF
OSN-Blazingly Fast GenAI App Development With Java and Spring AI
Juarez Junior
Ā 
PPTX
Oracle application container cloud back end integration using node final
Getting value from IoT, Integration and Data Analytics
Ā 
PDF
DSS_A Solid Foundation for GenAI Apps - Exploring Architectural Blueprints fo...
Juarez Junior
Ā 
DOC
Java database programming with jdbc
sriram raj
Ā 
PPTX
4. J2EE.pptx
HariChandruduM
Ā 
PDF
1java Introduction
Adil Jafri
Ā 
jPrime 2023 - Revolutionize Java DB AppDev with Reactive Streams and Virtual ...
Juarez Junior
Ā 
BarcelonaJUG - A High-Speed Data Ingestion Service in Java Using MQTT, AMQP, ...
Juarez Junior
Ā 
Cloud Conference Day - A High-Speed Data Ingestion Service in Java Using MQTT...
Juarez Junior
Ā 
DeveloperWeek Europe 2023 - Revolutionize Java DB AppDev with Reactive Stream...
Juarez Junior
Ā 
Oracle CloudWorld 2023 - A High-Speed Data Ingestion Service in Java Using MQ...
Juarez Junior
Ā 
TDC Connections 2023 - Revolutionize Java DB AppDev with Reactive Streams and...
Juarez Junior
Ā 
DeveloperWeek Latin America 2023 - A High-Speed Data Ingestion Service in Jav...
Juarez Junior
Ā 
Quarkus Club_Java Virtual Threads & Pipelined Database Operations
Juarez Junior
Ā 
TDC Connections 2023 - A High-Speed Data Ingestion Service in Java Using MQTT...
Juarez Junior
Ā 
Melee Numerique 2022 - Revolutionize Java DB App Dev with Reactive Streams an...
Juarez Junior
Ā 
Rollin onj Rubyv3
Oracle
Ā 
JCON OpenBlend Slovenia 2023 - A High-Speed Data Ingestion Service in Java Us...
Juarez Junior
Ā 
What's New and Noteworthy on Oracle CAF 12.1.3
Bruno Borges
Ā 
ADBA (Asynchronous Database Access)
Logico
Ā 
OSN-Blazingly Fast GenAI App Development With Java and Spring AI
Juarez Junior
Ā 
Oracle application container cloud back end integration using node final
Getting value from IoT, Integration and Data Analytics
Ā 
DSS_A Solid Foundation for GenAI Apps - Exploring Architectural Blueprints fo...
Juarez Junior
Ā 
Java database programming with jdbc
sriram raj
Ā 
4. J2EE.pptx
HariChandruduM
Ā 
1java Introduction
Adil Jafri
Ā 
Ad

More from Juarez Junior (20)

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

Recently uploaded (20)

PDF
Best ERP System for Manufacturing in India | Elite Mindz
Elite Mindz
Ā 
PDF
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
Ā 
PDF
Presentation about Hardware and Software in Computer
snehamodhawadiya
Ā 
PDF
Software Development Methodologies in 2025
KodekX
Ā 
PPTX
Stamford - Community User Group Leaders_ Agentblazer Status, AI Sustainabilit...
Amol Dixit
Ā 
PDF
Oracle AI Vector Search- Getting Started and what's new in 2025- AIOUG Yatra ...
Sandesh Rao
Ā 
PDF
AI Unleashed - Shaping the Future -Starting Today - AIOUG Yatra 2025 - For Co...
Sandesh Rao
Ā 
PDF
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
Ā 
PDF
Accelerating Oracle Database 23ai Troubleshooting with Oracle AHF Fleet Insig...
Sandesh Rao
Ā 
PPTX
The-Ethical-Hackers-Imperative-Safeguarding-the-Digital-Frontier.pptx
sujalchauhan1305
Ā 
PDF
A Day in the Life of Location Data - Turning Where into How.pdf
Precisely
Ā 
PDF
SparkLabs Primer on Artificial Intelligence 2025
SparkLabs Group
Ā 
PDF
Event Presentation Google Cloud Next Extended 2025
minhtrietgect
Ā 
PDF
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
Ā 
PDF
The Evolution of KM Roles (Presented at Knowledge Summit Dublin 2025)
Enterprise Knowledge
Ā 
PDF
DevOps & Developer Experience Summer BBQ
AUGNYC
Ā 
PDF
Orbitly Pitch Deck|A Mission-Driven Platform for Side Project Collaboration (...
zz41354899
Ā 
PDF
Chapter 2 Digital Image Fundamentals.pdf
Getnet Tigabie Askale -(GM)
Ā 
PDF
CIFDAQ'S Market Insight: BTC to ETH money in motion
CIFDAQ
Ā 
PDF
REPORT: Heating appliances market in Poland 2024
SPIUG
Ā 
Best ERP System for Manufacturing in India | Elite Mindz
Elite Mindz
Ā 
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
Ā 
Presentation about Hardware and Software in Computer
snehamodhawadiya
Ā 
Software Development Methodologies in 2025
KodekX
Ā 
Stamford - Community User Group Leaders_ Agentblazer Status, AI Sustainabilit...
Amol Dixit
Ā 
Oracle AI Vector Search- Getting Started and what's new in 2025- AIOUG Yatra ...
Sandesh Rao
Ā 
AI Unleashed - Shaping the Future -Starting Today - AIOUG Yatra 2025 - For Co...
Sandesh Rao
Ā 
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
Ā 
Accelerating Oracle Database 23ai Troubleshooting with Oracle AHF Fleet Insig...
Sandesh Rao
Ā 
The-Ethical-Hackers-Imperative-Safeguarding-the-Digital-Frontier.pptx
sujalchauhan1305
Ā 
A Day in the Life of Location Data - Turning Where into How.pdf
Precisely
Ā 
SparkLabs Primer on Artificial Intelligence 2025
SparkLabs Group
Ā 
Event Presentation Google Cloud Next Extended 2025
minhtrietgect
Ā 
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
Ā 
The Evolution of KM Roles (Presented at Knowledge Summit Dublin 2025)
Enterprise Knowledge
Ā 
DevOps & Developer Experience Summer BBQ
AUGNYC
Ā 
Orbitly Pitch Deck|A Mission-Driven Platform for Side Project Collaboration (...
zz41354899
Ā 
Chapter 2 Digital Image Fundamentals.pdf
Getnet Tigabie Askale -(GM)
Ā 
CIFDAQ'S Market Insight: BTC to ETH money in motion
CIFDAQ
Ā 
REPORT: Heating appliances market in Poland 2024
SPIUG
Ā 

CloudLand - Revolutionize Java DB AppDev with Reactive Streams and Virtual Threads

  • 1. Revolutionize Java Database App Development with Reactive Streams and Virtual Threads CloudLand 2023 Juarez Barbosa Junior @juarezjunior Sr. Principal Java Developer Evangelist ORACLE Copyright Ā© 2023, Oracle and/or its affiliates
  • 2. About me • Juarez Barbosa Junior - @juarezjunior • Senior Principal Java Developer Evangelist • 27 years of experience in IT • 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
  • 3. 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
  • 4. Copyright Ā© 2023, Oracle and/or its affiliates Java App Dev with Oracle Database
  • 5. 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
  • 6. 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
  • 7. 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
  • 8. 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
  • 9. 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
  • 10. 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()
  • 11. 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)
  • 12. 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
  • 13. 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
  • 14. 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.
  • 15. 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+
  • 16. 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"))); }
  • 17. 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
  • 18. 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
  • 19. 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
  • 20. 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
  • 21. 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
  • 22. 3 membership tiers Connect: @oracleace facebook.com/OracleACEs [email protected] 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
  • 23. Create your FREE Cloud Account • Go to https://signup.cloud.oracle.com/ Copyright Ā© 2023, Oracle and/or its affiliates
  • 24. About me • Juarez Barbosa Junior - @juarezjunior • Senior Principal Java Developer Evangelist • 27 years of experience in IT • 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
  • 25. Thank you! 25 Copyright Ā© 2023, Oracle and/or its affiliates | Confidential: Internal