Practical Cloud-Native Java Development with MicroProfile

Book description

Written by leading MicroProfile experts, this book provides you with best practices for building enterprise-grade cloud-native applications using MicroProfile 4.1 and running them on Open Liberty with Docker, Kubernetes, and Istio

Key Features

  • Apply your knowledge of MicroProfile APIs to develop cloud-native applications
  • Use MicroProfile Health to provide the startup, liveness, and readiness status of your enterprise application
  • Build an end-to-end stock trader project and containerize it to deploy to the cloud with Istio interaction

Book Description

In this cloud-native era, most applications are deployed in a cloud environment that is public, private, or a combination of both. To ensure that your application performs well in the cloud, you need to build an application that is cloud native. MicroProfile is one of the most popular frameworks for building cloud-native applications, and fits well with Kubernetes. As an open standard technology, MicroProfile helps improve application portability across all of MicroProfile's implementations.

Practical Cloud-Native Java Development with MicroProfile is a comprehensive guide that helps you explore the advanced features and use cases of a variety of Jakarta and MicroProfile specifications. You'll start by learning how to develop a real-world stock trader application, and then move on to enhancing the application and adding day-2 operation considerations. You'll gradually advance to packaging and deploying the application. The book demonstrates the complete process of development through to deployment and concludes by showing you how to monitor the application's performance in the cloud. By the end of this book, you will master MicroProfile's latest features and be able to build fast and efficient cloud-native applications.

What you will learn

  • Understand best practices for applying the 12-Factor methodology while building cloud-native applications
  • Create client-server architecture using MicroProfile Rest Client and JAX-RS
  • Configure your cloud-native application using MicroProfile Config
  • Secure your cloud-native application with MicroProfile JWT
  • Become well-versed with running your cloud-native applications in Open Liberty
  • Grasp MicroProfile Open Tracing and learn how to use Jaeger to view trace spans
  • Deploy Docker containers to Kubernetes and understand how to use ConfigMap and Secrets from Kubernetes

Who this book is for

This book is for Java application developers and architects looking to build efficient applications using an open standard framework that performs well in the cloud. DevOps engineers who want to understand how cloud-native applications work will also find this book useful. A basic understanding of Java, Docker, Kubernetes, and cloud is needed to get the most out of this book.

Table of contents

  1. Practical Cloud-Native Java Development with MicroProfile
  2. Contributors
  3. About the authors
  4. About the reviewers
  5. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
    4. Download the example code files
    5. Download the color images
    6. Conventions used
    7. Get in touch
    8. Share Your Thoughts
  6. Section 1: Cloud-Native Applications
  7. Chapter 1: Cloud-Native Applications
    1. What is a cloud-native application?
    2. Introducing distributed computing
    3. Exploring cloud-native application architectures
      1. Microservices
      2. Monoliths
      3. Macroservices
      4. Function as a Service
      5. Event sourcing
    4. Cloud-native development best practices
      1. Twelve-Factor App
      2. Other best practices
    5. Summary
  8. Chapter 2: How Does MicroProfile Fit into Cloud-Native Application Development?
    1. MicroProfile overview
      1. History of MicroProfile
      2. Characteristics of MicroProfile
    2. MicroProfile specifications
      1. Platform release
      2. Standalone releases
    3. MicroProfile Starter
      1. Accessing MicroProfile Starter via the web
      2. Accessing MicroProfile Starter via the command line
      3. Accessing MicroProfile Starter via an IDE plugin
      4. IntelliJ IDEA plugin
    4. Summary
  9. Chapter 3: Introducing the IBM Stock Trader Cloud-Native Application
    1. Overview of the IBM Stock Trader application
      1. UIs
      2. Architectural diagram
    2. Mandatory microservices and external services
      1. Trader
      2. Broker
      3. Portfolio
      4. Stock Quote
    3. Optional microservices and external services
      1. Tradr
      2. Account
      3. Trade History
      4. Messaging
      5. Notifications
      6. Collector
      7. Looper
    4. Summary
  10. Section 2: MicroProfile 4.1 Deep Dive
  11. Chapter 4: Developing Cloud-Native Applications
    1. Technical requirements
    2. Developing a RESTful service with JAX-RS
      1. Hello World!
      2. A more real-world example
      3. Entity providers and ParamConverter
      4. Intercepting requests and responses
      5. Dynamic providers
      6. Async
      7. Context injection
    3. Managing the payload with JSON-P and JSON-B
      1. JSON-P
      2. JSON-B
    4. Consuming RESTful services with the MicroProfile Rest Client
      1. JAX-RS Client APIs
      2. MicroProfile Rest Client
      3. Client-side providers
      4. Async
      5. Propagating HTTP headers from server to client
    5. Managing life cycle and DI with CDI
      1. Scopes
      2. Injection
    6. Summary
  12. Chapter 5: Enhancing Cloud-Native Applications
    1. Configuring cloud-native applications using MicroProfile Config
      1. Storing configuration
      2. Removing properties
      3. Converters
      4. Config lookup
      5. Building a Config instance yourself
      6. Making the MicroProfile Config API available
    2. Making a cloud application resilient using MicroProfile Fault tolerance
      1. @Asynchronous
      2. @Retry
      3. @Timeout
      4. @CircuitBreaker
      5. The Bulkhead pattern
      6. Fallback
      7. Using Fault Tolerance annotations together
      8. Fault Tolerance configuration
      9. Making the MicroProfile Fault Tolerance API available
    3. Documenting cloud native applications using MicroProfile OpenAPI
      1. Applying MicroProfile OpenAPI annotations on JAX-RS operations
      2. Using a programming model to generate documentation
      3. Using pre-generated OpenAPI documents
      4. Applying filters to the OpenAPI document
      5. MicroProfile OpenAPI configuration
      6. Viewing an OpenAPI document
      7. Making MicroProfile OpenAPI APIs available
    4. Securing cloud-native applications using MicroProfile JWT
      1. JWT format
      2. How does MicroProfile JWT work?
      3. Where to find the public key and private key
      4. How to make MicroProfile JWT available to applications?
    5. Summary
  13. Chapter 6: Observing and Monitoring Cloud-Native Applications
    1. Technical requirements
    2. Determining the health of your cloud-native application using MicroProfile Health
      1. The importance of MicroProfile Health in a cloud-native application
      2. MicroProfile Health technology overview
      3. Instrumenting health check procedures
      4. Retrieving health check data
      5. MicroProfile health checks with Kubernetes' liveness, readiness, and startup probes
    3. Instrumenting metrics on your cloud-native application using MicroProfile Metrics
      1. The importance of MicroProfile Metrics in a cloud-native application
      2. MicroProfile Metrics technology overview
      3. The seven metric types
      4. The metric model
      5. Instrumenting metrics
      6. Visualizing metric data with Prometheus and Grafana
    4. Tracing your cloud-native application using MicroProfile OpenTracing
      1. The importance of and an overview of MicroProfile OpenTracing in a cloud-native application
      2. Auto-instrumenting JAX-RS requests
      3. Instrumenting the @Traced annotation and injecting a tracer
      4. Visualizing traces with Jaeger
    5. Summary
  14. Chapter 7: MicroProfile Ecosystem with Open Liberty, Docker, and Kubernetes
    1. Technical requirements
    2. Deploying cloud-native applications to Open Liberty
    3. Containerizing cloud-native applications using Docker
      1. The container image
    4. Deploying cloud-native applications to Kubernetes
      1. MicroProfile Health in Kubernetes
      2. MicroProfile Config in Kubernetes
    5. MicroProfile and Service Mesh
    6. Summary
  15. Section 3: End-to-End Project Using MicroProfile
  16. Chapter 8: Building and Testing Your Cloud-Native Application
    1. Technical requirements
    2. Compiling the Stock Trader microservices
      1. GitHub
      2. Maven
    3. Building the Stock Trader container images
      1. Open Liberty
      2. Docker
    4. Testing the Stock Trader microservices
      1. Testing the frontend microservice
      2. Testing a backend microservice
    5. Using MicroProfile features in Stock Trader
      1. Implicit usage of MicroProfile features
    6. Summary
  17. Chapter 9: Deployment and Day 2 Operations
    1. Technical requirements
    2. Understanding the role of operators
    3. Installing the operator via the OpenShift console
      1. OperatorHub
      2. Installing the operator
    4. Deploying the application via the operator form UI
    5. Deploying the application via the CLI
    6. Understanding day 2 operations
      1. Scaling a microservice
      2. Upgrading a microservice
      3. Performing problem determination
    7. Summary
  18. Section 4: MicroProfile Standalone Specifications and the Future
  19. Chapter 10: Reactive Cloud-Native Applications
    1. Differentiating between imperative and reactive applications
    2. Using MicroProfile Context Propagation to manage context
      1. Using ManagedExecutor to propagate context
      2. Using ThreadContext to propagate context
    3. Using MicroProfile Reactive Messaging to build a reactive application
      1. Message
      2. Message acknowledgment
      3. Channel
      4. Message consumption using @Incoming
      5. Message production using @Outgoing
      6. Message processing using both @Incoming and @Outgoing
      7. Using Emitter to publish messages
      8. Using a connector to bridge to an external messaging technology
    4. Summary
  20. Chapter 11: MicroProfile GraphQL
    1. Technical requirements
    2. Understanding GraphQL basics and when to use it
    3. Building services with MP GraphQL
      1. Developing queries
      2. Developing mutations
      3. Writing entities
      4. Outsourcing
      5. Sending partial results using GraphQLException
    4. Consuming GraphQL services with client APIs
      1. Dynamic client
      2. Type-safe client
    5. Summary
  21. Chapter 12: MicroProfile LRA and the Future of MicroProfile
    1. Cloud-native application transactions
      1. Using MicroProfile LRA for cloud-native application transactions
      2. Making MicroProfile LRA available
    2. Using the latest MicroProfile platform release
    3. MicroProfile's technical roadmap
      1. Adopting OpenTelemetry in MicroProfile
      2. What is the future of MicroProfile Metrics?
      3. Adopting gPRC
      4. MicroProfile and Jakarta EE alignment
      5. Aligning MicroProfile 5.0 with Jakarta EE 9.1
    4. Summary
    5. Why subscribe?
  22. Other Books You May Enjoy
    1. Packt is searching for authors like you
    2. Share Your Thoughts

Product information

  • Title: Practical Cloud-Native Java Development with MicroProfile
  • Author(s): Emily Jiang, Andrew McCright, John Alcorn, David Chan, Alasdair Nottingham
  • Release date: September 2021
  • Publisher(s): Packt Publishing
  • ISBN: 9781801078801