Share E-Book
Scan to open this page

Scan with your phone to open this page

AuthorClement Escoffier & Ken Finnigan

Reactive systems and event-driven architecture are becoming indispensable to application design, and companies are taking note. Reactive systems ensure that applications are responsive, resilient, and elastic no matter what failures or errors may be occurring, while event-driven architecture offers a flexible and composable option for distributed systems. This practical book helps Java developers bring these approaches together using Quarkus 2.x, the Kubernetes-native Java framework. Clement Escoffier and Ken Finnigan show you how to take advantage of event-driven and reactive principles to build robust distributed systems, reducing latency and increasing throughput, particularly in microservices and serverless applications. You'll also get a foundation in Quarkus to help you create true Kubernetes-native applications for the cloud. Understand the fundamentals of reactive systems and event-driven architecture Learn how to use Quarkus to build reactive applications Combine Quarkus with Apache Kafka or AMQP to build reactive systems Develop microservices that utilize messages with Quarkus for use in event-driven architectures Learn how to integrate external messaging systems, such as Apache Kafka, with Quarkus Build applications with Quarkus using reactive systems and reactive programming concepts

AI Reading Assistant

Whole-book reading guide from stratified index samples; jump to passages in the text

AI guide
# Reactive Systems in Java: Resilient, Event-Driven Architecture with Quarkus ## 【One-Line Pitch】 A practical guide for Java developers who want to build resilient, event-driven distributed systems using Quarkus, combining reactive principles with Kubernetes-native deployment. If you're building microservices or cloud-native applications and want to move beyond traditional blocking architectures, this book shows you how—with real code and hands-on examples. ## 【Book Arc】 - **Opening (~0%–6%)**: Sets the stage for why reactive systems matter in the cloud era, covering the reactive manifesto principles (responsive, resilient, elastic, message-driven) and introducing the toolchain—Java, Maven, Docker, Kubernetes, and minikube—needed to follow along. - **Early (~6%–19%)**: Dives into Quarkus fundamentals, contrasting it with traditional JVM frameworks. You'll see concrete startup-time and memory-consumption comparisons, then walk through creating your first Quarkus project, using dev mode with live reload, and deploying to Kubernetes with minikube. - **Early (~19%–28%)**: Explores cloud-native concepts and the "dark side" of distributed systems—transient, persistent, and catastrophic failures. This section grounds you in why reactive architecture matters before you start building, using a simple service deployment to illustrate real-world distributed system challenges. - **Middle (~28%–38%)**: Introduces event-driven architecture fundamentals, distinguishing between commands and events with an e-commerce example. You'll learn how message passing enables location transparency and time decoupling, and why these properties are essential for building resilient systems. - **Middle (~38%–47%)**: Covers the mechanics of nonblocking I/O and reactive programming in Java. You'll see how callbacks, CompletableFuture, and CompletionStage APIs enable asynchronous composition, and why streams are the natural evolution for handling sequences of events. ## 【Key Takeaways】 - **Reactive systems embrace failure rather than hide it** (Early): Distributed systems will fail—transiently, persistently, or catastrophically—and reactive principles help you design for that reality instead of pretending it doesn't exist. This mindset shift is foundational for everything that follows. - **Quarkus solves Java's container problems** (Early): Traditional JVM frameworks suffer from slow startup and high memory consumption in containers. Quarkus uses build-time processing and native compilation to dramatically reduce both, making Java viable for serverless and microservice architectures. - **Cloud-native means designing for someone else's hardware** (Early): Running on the cloud means your application runs on machines you don't control. The Twelve-Factor App principles and Kubernetes primitives help, but your application must be designed to handle the distributed nature of the cloud. - **Commands create coupling; events enable autonomy** (Middle): When services call each other directly, you create a "distributed monolith" that collapses when any part fails. Publishing events instead of sending commands decouples services and makes your system resilient to individual component failures. - **Message brokers provide time decoupling** (Middle): With AMQP 1.0, Apache Kafka, or JMS, events are stored and delivered later, so consumers don't need to be available at the moment of publication. This decoupling is what makes asynchronous systems elastic and resilient. - **Nonblocking I/O is the key to scalability** (Middle): Blocking I/O limits concurrency to the number of threads you can create, inflating cloud bills and reducing deployment density. Nonblocking I/O with continuations lets a single thread handle many requests, dramatically improving throughput. - **Futures compose better than callbacks** (Middle): CompletableFuture and CompletionStage APIs handle both results and failures, support parallel composition with `allOf`, and enable recovery with `exceptionally`. But they fall short for streams—which is where reactive programming takes over. ## 【Reading Tips】 - **Skim the Quarkus setup chapters (Early) if you're already familiar with the framework**: The project generation, dev mode, and Kubernetes deployment walkthroughs are valuable but can be skimmed if you've built Quarkus apps before. Focus instead on the startup/memory comparison to understand *why* Quarkus matters. - **Deep-read the event-driven architecture chapter (Middle)**: The command-versus-event distinction and the e-commerce example are the conceptual heart of the book. Understanding this material is essential before you start building messaging-based systems. - **Pay close attention to the nonblocking I/O and reactive programming sections (Middle)**: These are the most technically dense parts. Work through the code examples—especially the callback-to-future-to-stream progression—to internalize how asynchronous composition works. - **Keep the toolchain ready**: You'll need Java, Maven, Docker, kubectl, and minikube installed to follow along. The book assumes you have these set up, so prepare your environment before diving in. - **Use the code repository**: The book references a GitHub repository with all examples organized by chapter. Clone it and run the examples as you read—especially the startup-measurement scripts and the reactive programming examples. ## 【Coverage Limits】 The excerpts cover the book's first half (roughly through reactive programming fundamentals). They do not cover the later chapters on Apache Kafka/AMQP integration, building message-driven microservices, or advanced Quarkus reactive features—those sections are beyond the scope of this guide. ##
Page 7
software has entirely changed. We can’t live without mobile applications and devices and now accept receiving notifications all day long. The Internet of Thi...
View in text
Excerpt 2
kus application INFO [io.quarkus] (Quarkus Main Thread) code-with-quarkus 1.0.0- SNAPSHOT on JVM \ dependencies are cached in a layer separate from the appli...
View in text
Excerpt 3
r the pod to be ready, as shown in Example 3-6. Example 3-6. Get the list of running pods > kubectl get pods NAME READY STATUS RESTARTS AGE quarkus-simple-se...
View in text
Excerpt 4
.out.println(luke.join() + " " + leia.join()); Futures make composing asynchronous actions much more straightforward than callbacks. Besides, futures encapsu...
View in text
Excerpt 5
ble has an added benefit. We minimize the amount of context switching performed when delegating execution to a worker thread. Anytime execution of the same r...
View in text
Excerpt 6
Stdev Latency 600.42us 357.14us 26.17ms 98.24% Req/Sec 8.44k 606.47 15.90k 93.71% 3364365 requests in 40.10s, 221.39MB read Requests/sec: 83895.54 Transfer/s...
View in text
Excerpt 7
initial four messages created when the application started. When Example 9-23 is done, create a new customer in a separate terminal window, as shown in Examp...
View in text
Excerpt 8
need to happen. Backpressure and Performance Considerations There is no way to have a truly reactive system without appropriate backpressure to avoid overloa...
View in text
Tags
AI categories
BackendCloud NativeJava
ISBN: 1492091715
Publish Year: 2021
Language: English
Pages: 384
File Format: PDF
File Size: 5.2 MB
Text Preview (First 20 pages)
Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

Generating text preview…