Building Microservices with Micronaut®
eBook - ePub

Building Microservices with Micronaut®

Nirmal Singh, Zack Dawood, The Micronaut® Foundation

Share book
  1. 362 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Building Microservices with Micronaut®

Nirmal Singh, Zack Dawood, The Micronaut® Foundation

Book details
Book preview
Table of contents
Citations

About This Book

Explore different aspects of building modular microservices such as development, testing, maintenance, and deployment using the Micronaut frameworkKey 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 frameworkBook DescriptionThe open source Micronaut® framework is a JVM-based toolkit designed to create microservices quickly and easily. This book will help full-stack and Java developers build modular, high-performing, and reactive microservice-based apps using the Micronaut framework.You'll start by building microservices and learning about the core components, 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 projects 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 Micronaut projects, 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 the Framework.By the end of this book, you'll be able to build, test, deploy, and maintain your own microservice apps using the framework.What you will learn• Understand why the Micronaut framework is best suited for building microservices• Build web endpoints and services in the Micronaut framework• Safeguard microservices using Session, JWT, and OAuth in Micronaut projects• Get to grips with event-driven architecture in Micronaut applications• 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 projects• Get hands-on with the IoT using Alexa and the Micronaut frameworkWho this book is forThis 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.

Frequently asked questions

How do I cancel my subscription?
Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
Can/how do I download books?
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
What is the difference between the pricing plans?
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
What is Perlego?
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Do you support text-to-speech?
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Is Building Microservices with Micronaut® an online PDF/ePUB?
Yes, you can access Building Microservices with Micronaut® by Nirmal Singh, Zack Dawood, The Micronaut® Foundation in PDF and/or ePUB format, as well as other popular books in Informatica & Architettura di sistemi. We have over one million books available in our catalogue for you to explore.

Information

Year
2021
ISBN
9781800567399

Section 1: Core Concepts and Basics

This section kickstarts the microservices journey in the Micronaut framework while covering some fundamentals of microservices, microservices design patterns, and why Micronaut is the ideal framework for microservices development.
This section has the following chapter:
  • Chapter 1, Getting Started with Microservices Using the Micronaut Framework

Chapter 1: Getting Started with Microservices Using the Micronaut Framework

In recent times, there's been a good buzz about microservices and how the microservices architecture has been transformational in developing rapid, agile, and enterprise-grade web services to address the unique challenges and requirements of today's world. The microservices architecture has turned the page toward disciplining the standards on developing these web services. In this chapter, we will walk through the evolution of web services to microservices. We will quickly dive into some useful microservices design patterns. We will zero in on the key pitfalls in most of the traditional Java development frameworks and how their surface-level adoption to the microservices architecture has elevated performance and optimization issues. We will then explore how the Micronaut framework has addressed these performance and optimization issues in the microservices with an overhauled and ground-up approach to microservices development. Lastly, to get started with the Micronaut framework, we will set up the Micronaut CLI and work on a small hello world project.
In this chapter, we will focus on these topics in particular:
  • Introducing microservices and their evolution
  • Understanding microservices design patterns
  • Why Micronaut is the best choice for developing microservices
  • Getting started with the Micronaut framework
  • Working on the hello world project in the Micronaut framework
By the end of this chapter, you will have an understanding of how web services evolved in to microservices and why traditional Java frameworks are ineffective for developing microservices as compared to the Micronaut framework. Furthermore, we will also gain the practical knowledge to start using the Micronaut framework by working on a small project in the Micronaut framework.

Technical requirements

All the commands and technical instructions in this chapter are run on Windows 10 and mac OS X. Code examples covered in this chapter are available in the book's GitHub repository at https://github.com/PacktPublishing/Building-Microservices-with-Micronaut/tree/master/Chapter01.
The following tools need to be installed and set up in the development environment:
  • Java SDK: Version 13 or above (we used Java 14).
  • Maven: This is optional and only required if you would like to use Maven as the build system. However, we recommend having Maven set up on any development machine. Instructions to download and install Maven can be found at https://maven.apache.org/download.cgi.
  • Development IDE: Based on your preferences, any Java-based IDE can be used, but for the purpose of writing this chapter, IntelliJ was used.
  • Git: Instructions to download and install Git can be found at https://git-scm.com/downloads.

Introducing microservices and their evolution

Before we thoroughly jump into introducing and defining microservices, it will be helpful to know how microservices have evolved. In the late 1960s, Alan Kay coined the term object-oriented programming. Though it was a definitive idea, later it birthed the four pillars for building software solutions using object-oriented programming:
  • Encapsulation
  • Inheritance
  • Polymorphism
  • Abstraction
In a short mnemonic, it's known as EIPA. Since the inception of these four pillars, the software industry has seen the rise and fall of many programming languages, frameworks, design patterns, and so on. With each such adaption and idea, thinkers and tinkerers have tried to come closer to EIPA by keeping a modular design and loosely coupled yet tightly encapsulated application components. Over the last few decades, software teams have moved away from the art of object-oriented programming toward the science of object-oriented programming by systematically adopting these key pillars. This iterative journey is the evolution of microservices.
In the late 1980s and early 1990s, almost every enterprise application was exposed as either a command line or native desktop software. Applications were tightly connected to databases and it was almost as if the end user was directly interacting with the database with the application as a thin façade in between. It was the era of monolithic applications or client/server architecture.
In the proceeding diagram, we can see how users interacted with a monolith application:
Figure 1.1 – Monolithic client/server architecture
Figure 1.1 – Monolithic client/server architecture
As depicted in Figure 1.1, in monolithic client/server architecture, the application is tightly coupled to the database and the user interacts through a terminal façade or desktop application. In this architecture, it was painful to maintain good service-level agreements (SLAs). Almost all the key non-functional factors such as scalability, high availability, fault tolerance, and flexibility underperformed or failed.
To address some of these aspects service-oriented architecture (SOA) came into existence. In the 2000s, SOA was formalized in the industry with the definition of some standard protocols such as Simple Object Access Protocol (SOAP). Web Services Description Language (WSDL) was also created during this period. Web 2.0 applications were popular with Asynchronous JavaScript And XML (AJAX). Enterprise service bus and messaging systems were highly used in enterprise applications. Advancements in SOA catalyzed a new paradigm of delivering software solutions to end users: Software as a Service (SaaS). Instead of desktop applications and terminal clients, software solutions were delivered to end users over HTTP as hosted online services. In the proceeding diagram, we can see how users interacted with an SOA-based application:
Figure 1.2 – SOA
Figure 1.2 – SOA
As shown, SOA brought in some decoupling by separating the concerns between the web application, web server...

Table of contents