0%

Book Description

Vert.x in Action teaches you how to build production-quality reactive applications in Java. This book covers core Vert.x concepts, as well as the fundamentals of asynchronous and reactive programming. Learn to develop microservices by using Vert.x tools for database communications, persistent messaging, and test app resiliency. The patterns and techniques included here transfer to reactive technologies and frameworks beyond Vert.x.

Table of Contents

  1. Vert.x in Action
  2. Copyright
  3. dedication
  4. brief contents
  5. contents
  6. front matter
    1. foreword
    2. preface
    3. acknowledgments
    4. about this book
      1. Who should read this book
      2. How this book is organized: A roadmap
      3. About the code
      4. liveBook discussion forum
    5. about the author
    6. about the cover illustration
  7. Part 1. Fundamentals of asynchronous programming with Vert.x
  8. 1 Vert.x, asynchronous programming, and reactive systems
    1. 1.1 Being distributed and networked is the norm
    2. 1.2 Not living on an isolated island
    3. 1.3 There is no free lunch on the network
    4. 1.4 The simplicity of blocking APIs
    5. 1.5 Blocking APIs waste resources, increase costs
    6. 1.6 Asynchronous programming with non-blocking I/O
    7. 1.7 Multiplexing event-driven processing: The case of the event loop
    8. 1.8 What is a reactive system?
    9. 1.9 What else does reactive mean?
    10. 1.10 What is Vert.x?
    11. 1.11 Your first Vert.x application
      1. 1.11.1 Preparing the project
      2. 1.11.2 The VertxEcho class
      3. 1.11.3 The role of callbacks
      4. 1.11.4 So is this a reactive application?
    12. 1.12 What are the alternatives to Vert.x?
    13. Summary
  9. 2 Verticles: The basic processing units of Vert.x
    1. 2.1 Writing a verticle
      1. 2.1.1 Preparing the project
      2. 2.1.2 The verticle class
      3. 2.1.3 Running and first observations
    2. 2.2 More on verticles
      1. 2.2.1 Blocking and the event loop
      2. 2.2.2 Asynchronous notification of life-cycle events
      3. 2.2.3 Deploying verticles
      4. 2.2.4 Passing configuration data
    3. 2.3 When code needs to block
      1. 2.3.1 Worker verticles
      2. 2.3.2 The executeBlocking operation
    4. 2.4 So what is really in a verticle?
      1. 2.4.1 Verticles and their environment
      2. 2.4.2 More on contexts
      3. 2.4.3 Bridging Vert.x and non-Vert.x threading models
    5. Summary
  10. 3 Event bus: The backbone of a Vert.x application
    1. 3.1 What is the event bus?
      1. 3.1.1 Is the event bus just another message broker?
      2. 3.1.2 Point-to-point messaging
      3. 3.1.3 Request-reply messaging
      4. 3.1.4 Publish/subscribe messaging
    2. 3.2 The event bus in an example
      1. 3.2.1 Heat sensor verticle
      2. 3.2.2 Listener verticle
      3. 3.2.3 Sensor data verticle
      4. 3.2.4 HTTP server verticle
      5. 3.2.5 Bootstrapping the application
    3. 3.3 Clustering and the distributed event bus
      1. 3.3.1 Clustering in Vert.x
      2. 3.3.2 From event bus to distributed event bus
    4. Summary
  11. 4 Asynchronous data and event streams
    1. 4.1 Unified stream model
    2. 4.2 What is back-pressure?
    3. 4.3 Making a music-streaming jukebox
      1. 4.3.1 Features and usage
      2. 4.3.2 HTTP processing: The big picture
      3. 4.3.3 Jukebox verticle basics
      4. 4.3.4 Incoming HTTP connections
      5. 4.3.5 Downloading as efficiently as possible
      6. 4.3.6 Reading MP3 files, but not too fast
    4. 4.4 Parsing simple streams
    5. 4.5 Parsing complex streams
    6. 4.6 A quick note on the stream fetch mode
    7. Summary
  12. 5 Beyond callbacks
    1. 5.1 Composing asynchronous operations: The edge service example
      1. 5.1.1 Scenario
      2. 5.1.2 Heat sensor verticles
      3. 5.1.3 Snapshot service verticle
    2. 5.2 Callbacks
      1. 5.2.1 Implementation
      2. 5.2.2 Running
      3. 5.2.3 The “callback hell” is not the problem
    3. 5.3 Futures and promises
      1. 5.3.1 Futures and promises in Vert.x
      2. 5.3.2 Future-based APIs in Vert.x 4
      3. 5.3.3 Interoperability with CompletionStage APIs
      4. 5.3.4 Collector service with Vert.x futures
    4. 5.4 Reactive extensions
      1. 5.4.1 RxJava in a nutshell
      2. 5.4.2 RxJava and Vert.x
      3. 5.4.3 Collector service in RxJava
    5. 5.5 Kotlin coroutines
      1. 5.5.1 What is a coroutine?
      2. 5.5.2 Vert.x and Kotlin coroutines
      3. 5.5.3 Edge service with coroutines
    6. 5.6 Which model should I use?
    7. Summary
  13. 6 Beyond the event bus
    1. 6.1 Revisiting heat sensors with a service API
    2. 6.2 Return of the RPCs (remote procedure calls)
    3. 6.3 Defining a service interface
    4. 6.4 Service implementation
    5. 6.5 Enabling proxy code generation
    6. 6.6 Deploying event-bus services
    7. 6.7 Service proxies beyond callbacks
    8. 6.8 Testing and Vert.x
      1. 6.8.1 Using JUnit 5 with Vert.x
      2. 6.8.2 Testing DataVerticle
      3. 6.8.3 Running the tests
    9. Summary
  14. Part 2. Developing reactive services with Vert.x
  15. 7 Designing a reactive application
    1. 7.1 What makes an application reactive
    2. 7.2 The 10k steps challenge scenario
    3. 7.3 One application, many services
    4. 7.4 Service specifications
      1. 7.4.1 User profile service
      2. 7.4.2 Ingestion service
      3. 7.4.3 Activity service
      4. 7.4.4 Public API
      5. 7.4.5 User web application
      6. 7.4.6 Event stats service
      7. 7.4.7 Congrats service
      8. 7.4.8 Dashboard web application
    5. 7.5 Running the application
    6. Summary
  16. 8 The web stack
    1. 8.1 Exposing a public API
      1. 8.1.1 Routing HTTP requests
      2. 8.1.2 Making HTTP requests
    2. 8.2 Access control with JWT tokens
      1. 8.2.1 Using JWT tokens
      2. 8.2.2 What is in a JWT token?
      3. 8.2.3 Handling JWT tokens with Vert.x
      4. 8.2.4 Issuing JWT tokens with Vert.x
    3. 8.3 Cross-origin resource sharing (CORS)
      1. 8.3.1 What is the problem?
      2. 8.3.2 Supporting CORS with Vert.x
    4. 8.4 A modern web frontend
      1. 8.4.1 Vue.js
      2. 8.4.2 Vue.js application structure and build integration
      3. 8.4.3 Backend integration illustrated
      4. 8.4.4 Static content serving with Vert.x
    5. 8.5 Writing integration tests
    6. Summary
  17. 9 Messaging and event streaming with Vert.x
    1. 9.1 Event-driven services beyond HTTP with Vert.x
      1. 9.1.1 What Vert.x provides
      2. 9.1.2 The middleware and services that we’ll use
      3. 9.1.3 What is AMQP (and a message broker)?
      4. 9.1.4 What is Kafka?
    2. 9.2 Reliably ingesting messages over HTTP and AMQP
      1. 9.2.1 Ingesting from AMQP
      2. 9.2.2 Translating AMQP messages to Kafka records
      3. 9.2.3 Ingesting from HTTP
    3. 9.3 Sending congratulation emails
      1. 9.3.1 Listening for daily step update events
      2. 9.3.2 Sending emails
    4. 9.4 Integration tests
      1. 9.4.1 Ingestion testing
      2. 9.4.2 Congratulation email testing
    5. Summary
  18. 10 Persistent state management with databases
    1. 10.1 Databases and Vert.x
      1. 10.1.1 What the Eclipse Vert.x stack provides
      2. 10.1.2 A note on data/object mapping, and why you may not always need it
    2. 10.2 User profile service with MongoDB
      1. 10.2.1 Data model
      2. 10.2.2 User profile API verticle and initialization
      3. 10.2.3 Validating user input
      4. 10.2.4 Adding users in MongoDB
      5. 10.2.5 Authenticating a user
      6. 10.2.6 Fetching a user’s data
      7. 10.2.7 Updating a user’s data
    3. 10.3 Activity service with PostgreSQL
      1. 10.3.1 Data model
      2. 10.3.2 Opening a connection pool
      3. 10.3.3 Life of a device update event
      4. 10.3.4 Inserting a new record
      5. 10.3.5 Generating a device’s daily activity update
      6. 10.3.6 Activity API queries
    4. 10.4 Integration tests
      1. 10.4.1 Testing the user profile service
      2. 10.4.2 Testing the activity service API
      3. 10.4.3 Testing the activity service’s event handling
    5. Summary
  19. 11 End-to-end real-time reactive event processing
    1. 11.1 Advanced stream data processing with Kafka and RxJava
      1. 11.1.1 Enriching daily device updates to generate user updates
      2. 11.1.2 Computing device-update ingestion throughput using time-window aggregates
      3. 11.1.3 Computing per-city trends using aggregation discriminants and time windows
    2. 11.2 Real-time reactive web applications
      1. 11.2.1 Forwarding Kafka records to the Vert.x event bus
      2. 11.2.2 Bridging the event bus and web applications
      3. 11.2.3 From Kafka to live web application updates
    3. 11.3 Streams and state
      1. 11.3.1 A stream of updates
      2. 11.3.2 Hydrating the ranking state
      3. 11.3.3 Periodically updating rankings from the updates stream
    4. Summary
  20. 12 Toward responsiveness with load and chaos testing
    1. 12.1 Initial experiments: Is the performance any good?
      1. 12.1.1 Some considerations before load testing
      2. 12.1.2 Simulating users with Locust
      3. 12.1.3 Load testing the API with Hey
    2. 12.2 Let’s do some chaos engineering
      1. 12.2.1 Test plan
      2. 12.2.2 Chaos testing with Pumba
      3. 12.2.3 We are not resilient (yet)
    3. 12.3 From “scalable” to “scalable and resilient”
      1. 12.3.1 Enforcing timeouts
      2. 12.3.2 Using a circuit breaker
      3. 12.3.3 Resiliency and fallback strategies
    4. Summary
  21. 13 Final notes: Container-native Vert.x
    1. 13.1 Heat sensors in a cloud
      1. 13.1.1 Heat sensor service
      2. 13.1.2 Sensor gateway
      3. 13.1.3 Heat API
      4. 13.1.4 Deploying to a local cluster
    2. 13.2 Making the services work in Kubernetes
      1. 13.2.1 Building container images
      2. 13.2.2 Clustering and Kubernetes
      3. 13.2.3 Kubernetes deployment and service resources
    3. 13.3 First-class Kubernetes citizens
      1. 13.3.1 Health checks
      2. 13.3.2 Metrics
    4. 13.4 The end of the beginning
    5. Summary
  22. index
3.144.113.30