SlideShare ist ein Scribd-Unternehmen logo
1 von 28
Downloaden Sie, um offline zu lesen
A High-Speed Data Ingestion Service in
Java Using MQTT, AMQP, and STOMP
DeveloperWeek Latin America 2023
Juarez Barbosa Junior - @juarezjunior
Sr. Principal Java Developer Evangelist
ORACLE
June 2023
Copyright © 2023, Oracle and/or its affiliates
About me
• Juarez Barbosa Junior - @juarezjunior
• Senior Principal Java Developer Evangelist
• Over 20 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
Copyright © 2023, Oracle and/or its affiliates
Java App Dev with Oracle Database
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 © 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 © 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
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 © 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)
⚫ PushPublisher API
// Push Publisher for Simple Usage
PushPublisher<Customer> pushPublisher =
ReactiveStreamsIngestion.pushPublisher();
pushPublisher.subscribe(rsi.subscriber());
// Ad-hoc usage
pushPublisher.accept(
new Customer(1, "John Doe", "North"));
// As a Consumer of a Stream
Customer[] customers = …
Stream
.of(customers)
.filter(c -> c.region.equals("NORTH"))
.forEach(pushPublisher::accept);
// As a Consumer for 3rd party Reactive Stream
// Libraries eg: Reactor https://projectreactor.io/
Flux
.just(
new Customer(1, "John Doe", "North"),
new Customer(2, "Jane Smith", "South"))
.concatWithValues(new Customer(3, "Bob", "South"))
.doOnComplete(() -> {System.out.println("Done!");})
.doOnCancel(() -> {System.out.println("Canceled!");})
.subscribe(pushPublisher::accept);
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
MOM - Message-Oriented Middleware
• A middleware component that allows
communication and exchanges the data
(messages).
• It involves passing data between applications
using a communication channel that carries self-
contained units of information (messages).
• In a MOM-based communication environment,
messages are sent and received asynchronously.
• MOM -> Apache ActiveMQ
AMQP – Advanced Message
Queuing Protocol
• The Advanced Message Queuing Protocol
(AMQP) is an open standard for passing
business messages between applications or
organizations.
• Realize the savings commoditization
brings; remove vendor lock-in
• Connect applications on different
platforms; choose the right platform for
the job
• Connect to business partners using a full-
featured open standard; remove
technical barriers to trade
• Position for innovations built upon the
foundation of AMQP
• Security, Reliability, Interoperability,
Standard, Openness
Copyright © 2023, Oracle and/or its affiliates
MQTT – Message Queuing
Telemetry Transport
• An OASIS standard messaging protocol for
the Internet of Things (IoT). It is designed as
an extremely lightweight publish/subscribe
messaging transport that is ideal for
connecting remote devices with a small code
footprint and minimal network bandwidth.
Copyright © 2023, Oracle and/or its affiliates
STOMP – Simple (or
Streaming) Text Oriented
Messaging Protocol
• STOMP provides an interoperable wire
format so that STOMP clients can
communicate with any STOMP message
broker to provide easy and widespread
messaging interoperability among many
languages, platforms and brokers..
Copyright © 2023, Oracle and/or its affiliates
Copyright © 2023, Oracle and/or its affiliates
ActiveMQ & JMS Message Consumer
⚫ ActiveMQ
⚫ ActiveMQ is a Java-based open-source message broker which supports REST API and
various wire-level protocols, such as MQTT, AMQP, and STOMP.
⚫ JMS Message Consumer
⚫ Like with any messaging-based application, you need to create a receiver that will
handle the messages that have been sent. The sample code snippet creates an AMQP
connection that connects to ActiveMQ using the given username, password,
hostname, and port number.
⚫ Port number 5672 is the default port that ActiveMQ is listening to over the AMQP
protocol when it starts up. It also creates a topic subscriber (consumer) to receive
messages that have been published to the "event" topic.
Copyright © 2023, Oracle and/or its affiliates
ActiveMQ & JMS Message Consumer
Copyright © 2023, Oracle and/or its affiliates
Demo #3: Architecture
Copyright © 2023, Oracle and/or its affiliates
Demo #3: Project Structure
Copyright © 2022, Oracle and/or its affiliates
References
• 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
• 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 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
Create your FREE
Cloud Account
• Go to
https://signup.cloud.oracle.c
om/
Copyright © 2023, Oracle and/or its affiliates
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
About me
• Juarez Barbosa Junior - @juarezjunior
• Senior Principal Java Developer Evangelist
• Over 20 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!
28
Copyright © 2023, Oracle and/or its affiliates | Confidential: Internal

Weitere ähnliche Inhalte

Ähnlich wie DeveloperWeek Latin America 2023 - A High-Speed Data Ingestion Service in Java Using MQTT, AMQP, and STOMP

Ähnlich wie DeveloperWeek Latin America 2023 - A High-Speed Data Ingestion Service in Java Using MQTT, AMQP, and STOMP (20)

CloudLand - Revolutionize Java DB AppDev with Reactive Streams and Virtual Th...
CloudLand - Revolutionize Java DB AppDev with Reactive Streams and Virtual Th...CloudLand - Revolutionize Java DB AppDev with Reactive Streams and Virtual Th...
CloudLand - Revolutionize Java DB AppDev with Reactive Streams and Virtual Th...
 
BarcelonaJUG - Revolutionize Java Database Application Development with React...
BarcelonaJUG - Revolutionize Java Database Application Development with React...BarcelonaJUG - Revolutionize Java Database Application Development with React...
BarcelonaJUG - Revolutionize Java Database Application Development with React...
 
Porto Tech Hub Conference 2023 - Revolutionize Java DB AppDev with Reactive S...
Porto Tech Hub Conference 2023 - Revolutionize Java DB AppDev with Reactive S...Porto Tech Hub Conference 2023 - Revolutionize Java DB AppDev with Reactive S...
Porto Tech Hub Conference 2023 - Revolutionize Java DB AppDev with Reactive S...
 
jPrime 2023 - Revolutionize Java DB AppDev with Reactive Streams and Virtual ...
jPrime 2023 - Revolutionize Java DB AppDev with Reactive Streams and Virtual ...jPrime 2023 - Revolutionize Java DB AppDev with Reactive Streams and Virtual ...
jPrime 2023 - Revolutionize Java DB AppDev with Reactive Streams and Virtual ...
 
Cloud Conference Day - Revolutionize Java Database App Development with React...
Cloud Conference Day - Revolutionize Java Database App Development with React...Cloud Conference Day - Revolutionize Java Database App Development with React...
Cloud Conference Day - Revolutionize Java Database App Development with React...
 
CloudTalks - Revolutionize Java DB AppDev with Reactive Streams and Virtual T...
CloudTalks - Revolutionize Java DB AppDev with Reactive Streams and Virtual T...CloudTalks - Revolutionize Java DB AppDev with Reactive Streams and Virtual T...
CloudTalks - Revolutionize Java DB AppDev with Reactive Streams and Virtual T...
 
Real time web apps
Real time web appsReal time web apps
Real time web apps
 
Java Library for High Speed Streaming Data
Java Library for High Speed Streaming Data Java Library for High Speed Streaming Data
Java Library for High Speed Streaming Data
 
Node.js and Oracle Database: New Development Techniques
Node.js and Oracle Database: New Development TechniquesNode.js and Oracle Database: New Development Techniques
Node.js and Oracle Database: New Development Techniques
 
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
 
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...
 
Shopzilla On Concurrency
Shopzilla On ConcurrencyShopzilla On Concurrency
Shopzilla On Concurrency
 
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®, ...
 
A practical introduction to Oracle NoSQL Database - OOW2014
A practical introduction to Oracle NoSQL Database - OOW2014A practical introduction to Oracle NoSQL Database - OOW2014
A practical introduction to Oracle NoSQL Database - OOW2014
 
Whats new in Autonomous Database in 2022
Whats new in Autonomous Database in 2022Whats new in Autonomous Database in 2022
Whats new in Autonomous Database in 2022
 
Java dev mar_2021_keynote
Java dev mar_2021_keynoteJava dev mar_2021_keynote
Java dev mar_2021_keynote
 
Privacy Preservation in cloud Environment using AES Algorithm
Privacy Preservation in cloud Environment using AES AlgorithmPrivacy Preservation in cloud Environment using AES Algorithm
Privacy Preservation in cloud Environment using AES Algorithm
 
DeveloperWeek Europe 2023 - Revolutionize Java DB AppDev with Reactive Stream...
DeveloperWeek Europe 2023 - Revolutionize Java DB AppDev with Reactive Stream...DeveloperWeek Europe 2023 - Revolutionize Java DB AppDev with Reactive Stream...
DeveloperWeek Europe 2023 - Revolutionize Java DB AppDev with Reactive Stream...
 
Coherence RoadMap 2018
Coherence RoadMap 2018Coherence RoadMap 2018
Coherence RoadMap 2018
 
4. J2EE.pptx
4. J2EE.pptx4. J2EE.pptx
4. J2EE.pptx
 

Mehr von Juarez Junior

Mehr von Juarez Junior (13)

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...
 
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
 
TDC Connections 2023 - Revolutionize Java DB AppDev with Reactive Streams and...
TDC Connections 2023 - Revolutionize Java DB AppDev with Reactive Streams and...TDC Connections 2023 - Revolutionize Java DB AppDev with Reactive Streams and...
TDC Connections 2023 - Revolutionize Java DB AppDev with Reactive Streams and...
 
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...
 
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...
 
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
 

Kürzlich hochgeladen

Kürzlich hochgeladen (20)

PLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. StartupsPLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. Startups
 
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdfThe Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
 
ECS 2024 Teams Premium - Pretty Secure
ECS 2024   Teams Premium - Pretty SecureECS 2024   Teams Premium - Pretty Secure
ECS 2024 Teams Premium - Pretty Secure
 
Designing for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at ComcastDesigning for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at Comcast
 
How we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfHow we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdf
 
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on ThanabotsContinuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
 
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
 
WebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM PerformanceWebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM Performance
 
IESVE for Early Stage Design and Planning
IESVE for Early Stage Design and PlanningIESVE for Early Stage Design and Planning
IESVE for Early Stage Design and Planning
 
Microsoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - QuestionnaireMicrosoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - Questionnaire
 
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
 
Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024
 
Google I/O Extended 2024 Warsaw
Google I/O Extended 2024 WarsawGoogle I/O Extended 2024 Warsaw
Google I/O Extended 2024 Warsaw
 
AI mind or machine power point presentation
AI mind or machine power point presentationAI mind or machine power point presentation
AI mind or machine power point presentation
 
1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT
1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT
1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT
 
Easier, Faster, and More Powerful – Notes Document Properties Reimagined
Easier, Faster, and More Powerful – Notes Document Properties ReimaginedEasier, Faster, and More Powerful – Notes Document Properties Reimagined
Easier, Faster, and More Powerful – Notes Document Properties Reimagined
 
State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!
 
Syngulon - Selection technology May 2024.pdf
Syngulon - Selection technology May 2024.pdfSyngulon - Selection technology May 2024.pdf
Syngulon - Selection technology May 2024.pdf
 
What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024
 
TopCryptoSupers 12thReport OrionX May2024
TopCryptoSupers 12thReport OrionX May2024TopCryptoSupers 12thReport OrionX May2024
TopCryptoSupers 12thReport OrionX May2024
 

DeveloperWeek Latin America 2023 - A High-Speed Data Ingestion Service in Java Using MQTT, AMQP, and STOMP

  • 1. A High-Speed Data Ingestion Service in Java Using MQTT, AMQP, and STOMP DeveloperWeek Latin America 2023 Juarez Barbosa Junior - @juarezjunior Sr. Principal Java Developer Evangelist ORACLE June 2023 Copyright © 2023, Oracle and/or its affiliates
  • 2. About me • Juarez Barbosa Junior - @juarezjunior • Senior Principal Java Developer Evangelist • Over 20 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. Copyright © 2023, Oracle and/or its affiliates Java App Dev with Oracle Database
  • 4. 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
  • 5. 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
  • 6. 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
  • 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 © 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
  • 12. Copyright © 2023, Oracle and/or its affiliates Demo # 2: Reactive Streams Ingestion (RSI) ⚫ PushPublisher API // Push Publisher for Simple Usage PushPublisher<Customer> pushPublisher = ReactiveStreamsIngestion.pushPublisher(); pushPublisher.subscribe(rsi.subscriber()); // Ad-hoc usage pushPublisher.accept( new Customer(1, "John Doe", "North")); // As a Consumer of a Stream Customer[] customers = … Stream .of(customers) .filter(c -> c.region.equals("NORTH")) .forEach(pushPublisher::accept); // As a Consumer for 3rd party Reactive Stream // Libraries eg: Reactor https://projectreactor.io/ Flux .just( new Customer(1, "John Doe", "North"), new Customer(2, "Jane Smith", "South")) .concatWithValues(new Customer(3, "Bob", "South")) .doOnComplete(() -> {System.out.println("Done!");}) .doOnCancel(() -> {System.out.println("Canceled!");}) .subscribe(pushPublisher::accept);
  • 13. 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
  • 14. 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
  • 15. Copyright © 2023, Oracle and/or its affiliates MOM - Message-Oriented Middleware • A middleware component that allows communication and exchanges the data (messages). • It involves passing data between applications using a communication channel that carries self- contained units of information (messages). • In a MOM-based communication environment, messages are sent and received asynchronously. • MOM -> Apache ActiveMQ
  • 16. AMQP – Advanced Message Queuing Protocol • The Advanced Message Queuing Protocol (AMQP) is an open standard for passing business messages between applications or organizations. • Realize the savings commoditization brings; remove vendor lock-in • Connect applications on different platforms; choose the right platform for the job • Connect to business partners using a full- featured open standard; remove technical barriers to trade • Position for innovations built upon the foundation of AMQP • Security, Reliability, Interoperability, Standard, Openness Copyright © 2023, Oracle and/or its affiliates
  • 17. MQTT – Message Queuing Telemetry Transport • An OASIS standard messaging protocol for the Internet of Things (IoT). It is designed as an extremely lightweight publish/subscribe messaging transport that is ideal for connecting remote devices with a small code footprint and minimal network bandwidth. Copyright © 2023, Oracle and/or its affiliates
  • 18. STOMP – Simple (or Streaming) Text Oriented Messaging Protocol • STOMP provides an interoperable wire format so that STOMP clients can communicate with any STOMP message broker to provide easy and widespread messaging interoperability among many languages, platforms and brokers.. Copyright © 2023, Oracle and/or its affiliates
  • 19. Copyright © 2023, Oracle and/or its affiliates ActiveMQ & JMS Message Consumer ⚫ ActiveMQ ⚫ ActiveMQ is a Java-based open-source message broker which supports REST API and various wire-level protocols, such as MQTT, AMQP, and STOMP. ⚫ JMS Message Consumer ⚫ Like with any messaging-based application, you need to create a receiver that will handle the messages that have been sent. The sample code snippet creates an AMQP connection that connects to ActiveMQ using the given username, password, hostname, and port number. ⚫ Port number 5672 is the default port that ActiveMQ is listening to over the AMQP protocol when it starts up. It also creates a topic subscriber (consumer) to receive messages that have been published to the "event" topic.
  • 20. Copyright © 2023, Oracle and/or its affiliates ActiveMQ & JMS Message Consumer
  • 21. Copyright © 2023, Oracle and/or its affiliates Demo #3: Architecture
  • 22. Copyright © 2023, Oracle and/or its affiliates Demo #3: Project Structure
  • 23. Copyright © 2022, Oracle and/or its affiliates References • 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 • 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
  • 24. 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
  • 25. Create your FREE Cloud Account • Go to https://signup.cloud.oracle.c om/ Copyright © 2023, Oracle and/or its affiliates
  • 26. 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
  • 27. About me • Juarez Barbosa Junior - @juarezjunior • Senior Principal Java Developer Evangelist • Over 20 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
  • 28. Thank you! 28 Copyright © 2023, Oracle and/or its affiliates | Confidential: Internal