Building Microservices with Micronaut: A quick-start guide to building high-performance reactive microservices for Java developers
- Length: 362 pages
- Edition: 1
- Language: English
- Publisher: Packt Publishing
- Publication Date: 2021-09-30
- ISBN-10: 1800564236
- ISBN-13: 9781800564237
- Sales Rank: #656834 (See Top 100 Books)
Explore different aspects of building modular microservices such as development, testing, maintenance, and deployment using the Micronaut framework
Key Features
- Learn how to build scalable, fast, and resilient microservices with this concise guide
- Explore the many advantages of using reflection-free, compile-time dependency injections and aspect-oriented programming
- Build cloud-native applications easily with the Micronaut framework
Book Description
The Micronaut® open source software is a JVM-based framework, designed to create microservices quickly and easily. This book will help full-stack and Java developers to build modular, high-performing, and reactive microservice-based apps using Micronaut.
You’ll start by building microservices and learning about the core components of Micronaut, such as ahead-of-time compilation, reflection-less dependency injection, and reactive baked-in HTTP clients and servers. Next, you will work on a real-time microservice application and learn how to integrate Micronaut with different kinds of relational and non-relational databases. You’ll also learn how to employ different security mechanisms to safeguard your microservices and integrate microservices using event-driven architecture in the Apache Kafka ecosystem. As you advance, you’ll get to grips with automated testing and popular testing tools. The book will help you understand how you can easily handle microservice concerns in the Micronaut framework, such as service discovery, API documentation, distributed configuration management, fallbacks, and circuit breakers. Finally, you’ll explore the deployment and maintenance aspects of microservices and get up to speed with the Internet of Things (IoT) using Micronaut.
By the end of this book, you’ll be able to build, test, deploy, and maintain your own microservice apps using Micronaut.
What you will learn
- Understand why Micronaut is best suited for building microservices
- Build web endpoints and services in the Micronaut framework
- Safeguard microservices using Session, JWT, and OAuth in Micronaut
- Get to grips with event-driven architecture in Micronaut
- Discover how to automate testing at various levels using built-in tools and testing frameworks
- Deploy your microservices to containers and cloud platforms
- Become well-versed with distributed logging, tracing, and monitoring in Micronaut
- Get hands-on with the IoT using Alexa and Micronaut
Who this book is for
This book is for developers who have been building microservices on traditional frameworks such as Spring Boot and are looking for a faster alternative. Intermediate-level knowledge of Java programming and implementing web services development in Java is required.
Table of Contents
- Getting Started with Microservices Using the Micronaut Framework
- Working on Data Access
- Working on the RESTful Web Services
- Securing the Microservices
- Integrating Microservices using the Event-Driven Architecture
- Testing the Microservices
- Handling Microservice Concerns
- Deploying Microservices
- Distributed logging, tracing and monitoring
- IoT with Micronaut
- Building enterprise grade microservices
Building Microservices with Micronaut® Foreword Contributors About the authors About the reviewer Preface Who this book is for What this book covers To get the most out of this book Download the example code files Download the color images Conventions used Get in touch Share Your Thoughts Section 1: Core Concepts and Basics Chapter 1: Getting Started with Microservices Using the Micronaut Framework Technical requirements Introducing microservices and their evolution Understanding microservices design patterns Decomposition design patterns Integration design patterns Data management patterns Cross-cutting patterns Why Micronaut is the best choice for developing microservices Getting started with the Micronaut framework Installing the Micronaut CLI on mac OS Installing the Micronaut CLI on Windows Working on a hello world project in the Micronaut framework Creating a hello world project using the Micronaut CLI Creating a hello world project using Micronaut Launch Summary Questions Section 2: Microservices Development Chapter 2: Working on Data Access Technical requirements Integrating with persistence in the Micronaut framework Integrating with a relational database using an ORM (Hibernate) framework Generating the pet-owner schema in PostgreSQL Creating a Micronaut application for the pet-owner microservice Creating the entity classes Defining relationships among entities Creating data access repositories Creating services for entities Performing basic CRUD operations Wrapping up Integrating with a relational database using a persistence (MyBatis) framework Generating the pet-clinic schema in PostgreSQL Generating a Micronaut application for the pet-clinic microservice Defining a MyBatis factory Creating the entity classes Defining the mappers (repositories) for the entities Creating services for entities Performing basic CRUD operations Wrapping up Integrating with a NoSQL database (MongoDB) Creating a vet-reviews collection in MongoDB Generating a Micronaut application for the pet-clinic-reviews microservice Configuring MongoDB in Micronaut Creating the entity class Creating a data access repository Creating a service for the entity Performing basic CRUD operations Wrapping up Summary Questions Chapter 3: Working on RESTful Web Services Technical requirements Working on restful microservices in the Micronaut framework Using DTOs for the endpoint payloads Implementing DTOs Using MapStruct to define mappers Modifying the services to use DTOs Creating the restful endpoints for a microservice Creating an endpoint for retrieving a list of resources Creating an endpoint for retrieving a specific resource Creating an endpoint for inserting a resource Creating an endpoint for updating a resource Creating an endpoint for deleting a resource Using Micronaut's HTTP server APIs Binding HTTP requests in the Micronaut framework Validating data Handling errors Versioning the APIs Using Micronaut's HTTP client APIs Performing an HTTP PUT operation Performing an HTTP POST operation Performing an HTTP PUT operation Performing an HTTP DELETE operation Summary Questions Chapter 4: Securing the Microservices Technical requirements Working on RESTful microservices in the Micronaut framework The basics of Micronaut security Securing service endpoints using session authentication Implementing a basic authentication provider Configuring authorizations for the service endpoints Using JWT authentication to secure the service endpoints Setting up Keycloak as the identity provider Securing the pet-clinic microservice using token-based authentication Using OAuth to secure service endpoints Setting up Okta as the identity provider Enabling SSL in the Micronaut framework Securing the pet-clinic-reviews microservice using OAuth Summary Questions Chapter 5: Integrating Microservices Using Event-Driven Architecture Technical requirements Understanding event-driven architecture Event messaging or a pub/sub model in an event-driven architecture Event streaming in event-driven architecture Event streaming with the Apache Kafka ecosystem Integrating microservices using event streaming Setting up the Apache Kafka ecosystem locally Implementing an event-producer client in the pet-clinic-reviews microservice Implementing an event consumer client in the pet-clinic microservice Summary Questions Section 3: Microservices Testing Chapter 6: Testing Microservices Technical requirements Understanding the testing pyramid Unit testing in the Micronaut framework Unit testing using JUnit 5 Service testing in the Micronaut framework Integration testing using Testcontainers Setting up the Testcontainers in the Micronaut application Writing integration tests using Testcontainers Summary Questions Section 4: Microservices Deployment Chapter 7: Handling Microservice Concerns Technical requirements Externalizing the application configuration Using distributed configuration management to externalize the configuration Documenting the service APIs Using Swagger to document the pet-owner service endpoints Implementing service discovery Implementing service discovery using Consul Implementing the API gateway Implementing the API gateway service Implementing the fault tolerance mechanisms Leveraging built-in mechanisms Summary Questions Chapter 8: Deploying Microservices Technical requirements Building the container artifacts Containerizing the Micronaut microservices using Jib Deploying the container artifacts Using docker-compose to deploy the pet-clinic services Summary Questions Section 5: Microservices Maintenance Chapter 9: Distributed Logging, Tracing, and Monitoring Technical requirements Distributed logging in Micronaut microservices Setting up ELK in Docker Integrating Logstash with Micronaut microservices Verifying the distributed logging in the pet-clinic application Distributed tracing in Micronaut microservices Implementing distributed tracing in Micronaut Verifying the distributed tracing in the pet-clinic application Distributed monitoring in Micronaut microservices Setting up Prometheus and Grafana in Docker Configuring microservices for distributed monitoring Verifying the distributed monitoring in the pet-clinic application Summary Questions Section 6: IoT with Micronaut and Closure Chapter 10: IoT with Micronaut Technical requirements Basics of IoT Working on the basics of Alexa skills Basics of Alexa skills Basics of intents Your first HelloWorld Alexa skill Testing your code Integrating Micronaut with Alexa Summary Questions Chapter 11: Building Enterprise-Grade Microservices Technical requirements Bringing it all together Architecting enterprise microservices Planning and analysis Design Develop Deploy Manage and maintain Understanding Micronaut's OpenAPI Scaling Micronaut Implementing Micronaut's microservices Summary Questions Assessment Chapter 10 Chapter 11 Why subscribe? Other Books You May Enjoy Packt is searching for authors like you Share Your Thoughts
Donate to keep this site alive
How to download source code?
1. Go to: https://github.com/PacktPublishing
2. In the Find a repository… box, search the book title: Building Microservices with Micronaut: A quick-start guide to building high-performance reactive microservices for Java developers
, sometime you may not get the results, please search the main title.
3. Click the book title in the search results.
3. Click Code to download.
1. Disable the AdBlock plugin. Otherwise, you may not get any links.
2. Solve the CAPTCHA.
3. Click download link.
4. Lead to download server to download.