O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Hands-On Enterprise Java Microservices with Eclipse MicroProfile

Book Description

An effective guide to designing, building, and deploying enterprise Java microservices with Eclipse MicroProfile

Key Features

  • Create cloud-native microservices with ease using this detailed guide
  • Avoid vendor lock-in when implementing microservices using Eclipse MicroProfile
  • Discover why MicroProfile is a great specification for building microservices in multi-cloud environments

Book Description

Eclipse MicroProfile has gained momentum in the industry as a multi-vendor, interoperable, community-driven specification. It is a major disruptor that allows organizations with large investments in enterprise Java to move to microservices without spending a lot on retraining their workforce.

This book is based on MicroProfile 2.2, however, it will guide you in running your applications in MicroProfile 3.0. You'll start by understanding why microservices are important in the digital economy and how MicroProfile addresses the need for enterprise Java microservices. You'll learn about the subprojects that make up a MicroProfile, its value proposition to organizations and developers, and its processes and governance. As you advance, the book takes you through the capabilities and code examples of MicroProfile's subprojects - Config, Fault Tolerance, Health Check, JWT Propagation, Metrics, and OpenTracing. Finally, you'll be guided in developing a conference application using Eclipse MicroProfile, and explore possible scenarios of what's next in MicroProfile with Jakarta EE.

By the end of this book, you'll have gained a clear understanding of Eclipse MicroProfile and its role in enterprise Java microservices.

What you will learn

  • Understand why microservices are important in the digital economy
  • Analyze how MicroProfile addresses the need for enterprise Java microservices
  • Test and secure your applications with Eclipse MicroProfile
  • Get to grips with various MicroProfile capabilities such as OpenAPI and Typesafe REST Client
  • Explore reactive programming with MicroProfile Stream and Messaging candidate APIs
  • Discover and implement coding best practices using MicroProfile

Who this book is for

If you're a Java developer who wants to create enterprise microservices, this book is for you. Familiarity with Java EE and the concept of microservices will help you get the most out of this book.

Downloading the example code for this ebook: You can download the example code files for this ebook on GitHub at the following link: https://github.com/PacktPublishing/Hands-On-Enterprise-Java-Microservices-with-Eclipse-MicroProfile. If you require support please email: customercare@packt.com

Table of Contents

  1. Title Page
  2. Copyright and Credits
    1. Hands-On Enterprise Java Microservices with Eclipse MicroProfile
  3. About Packt
    1. Why subscribe?
  4. Contributors
    1. About the authors
    2. About the reviewers
    3. Packt is searching for authors like you
  5. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
      1. Download the example code files
      2. Download the color images
      3. Conventions used
    4. Get in touch
      1. Reviews
  6. Section 1: MicroProfile in the Digital Economy
  7. Introduction to Eclipse MicroProfile
    1. Enterprise Java microservices
    2. Forces that fuel the digital economy
      1. Multi-speed IT
    3. Introducing Eclipse MicroProfile
    4. MicroProfile value proposition
    5. Summary
    6. Questions
  8. Governance and Contributions
    1. Current Eclipse MicroProfile governance
      1. Sandbox approach to open contribution
      2. Umbrella releases versus projects outside the umbrella
    2. MicroProfile Starter
      1. A quick tour of MicroProfile Starter
    3. Summary
    4. Questions
  9. Section 2: MicroProfile's Current Capabilities
  10. MicroProfile Config and Fault Tolerance
    1. Understanding Eclipse MicroProfile Config
      1. Reading configuration from the MicroProfile Config API
        1. The Config object
        2. The @ConfigProperty annotation
      2. Providing sources of configuration
        1. Default ConfigSources
        2. Custom ConfigSources implementations
      3. Using converters for high-level configuration
        1. Built-in converters
        2. Automatic converters
        3. Custom converters
    2. Understanding Eclipse MicroProfile Fault Tolerance
      1. MicroProfile Fault Tolerance in action
        1. The @Asynchronous policy
        2. The @Retry policy
        3. The @Fallback policy
        4. The @Timeout policy
        5. The @CircuitBreaker policy
        6. The @Bulkhead policy
        7. Tolerance with MicroProfile config
    3. Summary
    4. Questions
    5. Further reading
  11. MicroProfile Health Check and JWT Propagation
    1. Technical requirements
    2. Understanding health checks and how MicroProfile handles them
      1. The Health Check protocol and wire format
      2. The Health Check Java API
        1. Integration with the cloud platform
        2. Human operators
        3. Changes in Health Check response messages
    3. Using JSON Web Token Propagation in MicroProfile
      1. Recommendations for interoperability
        1. Required MP-JWT claims
        2. The high-level description of the MP-JWT API
        3. Sample code that uses MP-JWT
          1. Injection of JsonWebToken information
          2. Injection of JWT claim values
        4. Configuring authentication of JWTs
        5. Running the samples
    4. Summary
    5. Questions
  12. MicroProfile Metrics and OpenTracing
    1. MicroProfile Metrics
      1. Metadata
      2. Retrieving metrics from the server
        1. Accessing specific scopes
      3. Supplying application-specific metrics
        1. More types of metric
          1. Gauges
          2. Meter
          3. Histograms
          4. Timers
        2. Tagging
          1. Server-wide tags
          2. Per-metrics tags
      4. Using Prometheus to retrieve metrics
      5. New in MP-Metrics 2.0
        1. Change for counters – introducing ConcurrentGauge
        2. Tagging
        3. Changes in data output format
    2. MicroProfile OpenTracing
      1. OpenTracing project
      2. Configuration properties
      3. Automatic instrumentation
        1. JAX-RS
        2. MicroProfile Rest Client
      4. Explicit instrumentation
        1. @Traced annotation
        2. Tracer injection
      5. Tracing with Jaeger
    3. Summary
    4. Questions
  13. MicroProfile OpenAPI and Type-Safe REST Client
    1. Introduction to MicroProfile OpenAPI and its capabilities
      1. Configuration
      2. Generating the OpenAPI document
      3. MicroProfile OpenAPI annotations
        1. Usage examples
      4. Static OpenAPI files
      5. Programming model
      6. Using a filter for updates
    2. Introduction to the MicroProfile REST Client and its capabilities
      1. Defining the endpoint Interface
      2. MicroProfile REST Client programmatic API usage
      3. MicroProfile REST Client CDI usage
        1. MicroProfile Config integration
          1. Simplifying configuration keys
      4. Dealing with client headers
      5. Provider registration for advanced usage
        1. Provider priority
        2. Feature registration
        3. Default providers
      6. Exception mapping
        1. Default exception mapping
      7. Async support
    3. Summary
    4. Questions
  14. Section 3: MicroProfile Implementations and Roadmap
  15. MicroProfile Implementations, Quarkus, and Interoperability via the Conference Application
    1. Current MicroProfile implementations
      1. Thorntail
      2. Open Liberty
      3. Apache TomEE
      4. Payara Micro
      5. Hammock
      6. KumuluzEE
      7. Launcher
      8. Helidon
      9. Generating sample code for the current implementations
      10. Other projects that implement MicroProfile
    2. Quarkus
      1. How to quark a generated MicroProfile project
    3. MicroProfile interoperability – the conference application
    4. Summary
    5. Questions
  16. Section 4: A Working MicroProfile Example
  17. A Working Eclipse MicroProfile Code Sample
    1. Technical requirements
    2. Sample architecture of a multiservice MicroProfile application
      1. Running the sample application
        1. The Docker shell commands
        2. The Svcs1 shell command
        3. The Svcs2 shell command
        4. The web shell command
      2. Details of the sample application
        1. The Config tab
        2. The Health tab
        3. The Metrics tab
        4. The OpenTracing tab
        5. The OpenAPI tab
        6. The KeyCloak tab
        7. The JWT tab
        8. The RestClient tab
    3. Summary
    4. Questions
    5. Further reading
  18. Section 5: A Peek into the Future
  19. Reactive Programming and Future Developments
    1. Reactive programming work in Eclipse MicroProfile
      1. An overview of Reactive Messaging
        1. MicroProfile reactive messaging architecture
          1. Message shapes
        2. MicroProfile Reactive Streams operators
        3. MicroProfile Context Propagation
      2. MicroProfile reactive messaging examples
    2. MicroProfile future developments
      1. Projects outside the umbrella
        1. Long Running Actions
        2. Context Propagation
        3. GraphQL
          1. Differences between GraphQL and REST
          2. GraphQL and databases
      2. Projects in the sandbox
        1. MicroProfile Boost
      3. Eclipse MicroProfile and Jakarta EE
    3. Summary
    4. Questions
    5. Further reading
  20. Using MicroProfile in Multi-Cloud Environments
    1. Using Eclipse MicroProfile for cloud-native application development
      1. Microservices versus cloud native versus container native
      2. What about 12-factor applications?
      3. What about serverless and FaaS?
      4. Cloud-native application development
    2. Developing and running MicroProfile applications across clouds
      1. Bare-metal machines versus VMs versus containers
      2. Considerations when using MicroProfile in a hybrid cloud deployment
      3. Challenges when using MicroProfile OpenTracing in a multi-cloud deployment
      4. Considerations when using Eclipse MicroProfile in a service mesh
        1. Retry
        2. Fallback
        3. Fault injection in the service mesh
        4. Conclusion
    3. Summary
    4. Questions
  21. Assessments
    1. Chapter 1
    2. Chapter 2
    3. Chapter 3
    4. Chapter 4
    5. Chapter 5
    6. Chapter 6
    7. Chapter 7
    8. Chapter 8
    9. Chapter 9
    10. Chapter 10
  22. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think