Mastering Microservices with Java Table of Contents Mastering Microservices with Java Credits About the Author About the Reviewer www.PacktPub.com eBooks, discount offers, and more Why subscribe? Preface What this book covers What you need for this book Who this book is for Conventions Reader feedback Customer support Downloading the example code Errata Piracy Questions A Solution Approach Evolution of µServices Monolithic architecture overview Limitation of monolithic architecture versus its solution with µServices One dimension scalability Release rollback in case of failure Problems in adopting new technologies Alignment with Agile practices Ease of development – could be done better Microservices build pipeline Deployment using a container such as Docker Containers Docker Docker's architecture Docker image Docker container Deployment Summary Setting Up the Development Environment Spring Boot configuration Spring Boot overview Adding Spring Boot to the rest sample Adding a Jetty-embedded server Sample REST program Writing the REST controller class @RestController @RequestMapping @RequestParam @PathVariable Making a sample REST app executable Setting up the application build Running the Maven tool Executing with the Java command REST API testing using the Postman Chrome extension Some more positive test scenarios Negative test scenarios NetBeans IDE installation and setup References Summary Domain-Driven Design Domain-driven design fundamentals Building blocks Ubiquitous language Multilayered architecture Presentation layer Application layer Domain layer Infrastructure layer Artifacts of domain-driven design Entities Value objects Frequently asked questions Services Aggregates Repository Factory Modules Strategic design and principles Bounded context Continuous integration Context map Shared kernel Customer-supplier Conformist Anticorruption layer Separate ways Open host service Distillation Sample domain service Entity implementation Repository implementation Service implementation Summary Implementing a Microservice OTRS overview Developing and implementing µServices Restaurant µService Controller class API versioning Service classes Repository classes Entity classes Booking and user services Registration and Discovery service (Eureka service) Execution Testing References Summary Deployment and Testing An overview of microservice architecture using Netflix OSS Load balancing Client-side load balancing Server-side load balancing Circuit breaker and monitoring Using Hystrix's fallback methods Monitoring Setting up the Hystrix Dashboard Setting up Turbine Microservice deployment using containers Installation and configuration Docker Machine with GB Building Docker images with Maven Running Docker using Maven Integration testing with Docker Pushing the image to a registry Managing Docker containers References Summary Securing Microservices Enabling Secure Socket Layer Authentication and authorization OAuth 2.0 Usage of OAuth OAuth 2.0 specification – concise details OAuth 2.0 roles Resource owner Resource server Client Authorization server OAuth 2.0 client registration Client types Confidential client type Public client type Web application User agent-based application Native application Client identifier Client authentication OAuth 2.0 protocol endpoints Authorization endpoint Token endpoint Redirection endpoint OAuth 2.0 grant types Authorization code grant Authorization code requests and responses Implicit grant Implicit grant requests and responses Resource owner password credentials grant Client credentials grant OAuth implementation using Spring Security Authorization code grant Implicit grant Resource owner password credential grant Client credentials grant References Summary Consuming Services Using a Microservice Web App AngularJS framework overview MVC MVVM Modules Providers and services Scopes Controllers Filters Directives UI-Router Development of OTRS features Home page/restaurant list page index.html app.js restaurants.js restaurants.html Search Restaurants Restaurant details with reservation option restaurant.html Login page login.html login.js Reservation confirmation Setting up the web app Summary Best Practices and Common Principles Overview and mindset Best practices and principals Nanoservice (not recommended), size, and monolithic Continuous integration and deployment System/end-to-end test automation Self-monitoring and logging A separate data store for each microservice Transaction boundaries Microservices frameworks and tools Netflix Open Source Software (OSS) Build – Nebula Deployment and delivery – Spinnaker with Aminator Service registration and discovery – Eureka Service communication – Ribbon Circuit breaker – Hystrix Edge (proxy) server – Zuul Operational monitoring – Atlas Reliability monitoring service – Simian Army AWS resource monitoring – Edda On-host performance monitoring – Vector Distributed configuration management – Archaius Scheduler for Apache Mesos – Fenzo Cost and cloud utilization – Ice Other security tools – Scumblr and FIDO Scumblr Fully Integrated Defence Operation (FIDO) References Summary Troubleshooting Guide Logging and ELK stack A brief overview Elasticsearch Logstash Kibana ELK stack setup Installing Elasticsearch Installing Logstash Installing Kibana Tips for ELK stack implementation Use of correlation ID for service calls Let's see how we can tackle this problem Dependencies and versions Cyclic dependencies and their impact It needs to be analyzed while designing the system Maintaining different versions Let's explore more References Summary Index Mastering Microservices with Java N Nanoservice Antipattern reference link / References Nebula / Build – Nebula NetBeans download link / References NetBeans IDE installation / NetBeans IDE installation and setup download link / NetBeans IDE installation and setup setup / NetBeans IDE installation and setup reference link / NetBeans IDE installation and setup Netflix Eureka reference link / References Netflix Open Source Software (OSS) about / Netflix Open Source Software (OSS) Build - Nebula / Build – Nebula Nebula / Build – Nebula Spinnaker / Deployment and delivery – Spinnaker with Aminator Aminator / Deployment and delivery – Spinnaker with Aminator Eureka / Service registration and discovery – Eureka Ribbon / Service communication – Ribbon Hystrix / Circuit breaker – Hystrix Zuul / Edge (proxy) server – Zuul Atlas / Operational monitoring – Atlas Simian Army / Reliability monitoring service – Simian Army Edda / AWS resource monitoring – Edda Vector / On-host performance monitoring – Vector Archaius / Distributed configuration management – Archaius Fenzo / Scheduler for Apache Mesos – Fenzo Ice / Cost and cloud utilization – Ice Fully Integrated Defence Operation (FIDO) / Other security tools – Scumblr and FIDO Scumblr / Other security tools – Scumblr and FIDO Netflix Open Source Software Center (OSS) / An overview of microservice architecture using Netflix OSS Netflix Ribbon reference link / References Netflix Zuul reference link / References Node.js package manager (npm) about / Setting up the web app reference link / Setting up the web app O OAuth 2.0 about / OAuth 2.0 usage / Usage of OAuth specification / OAuth 2.0 specification – concise details roles / OAuth 2.0 roles client registration / OAuth 2.0 client registration protocol endpoints / OAuth 2.0 protocol endpoints grant types / OAuth 2.0 grant types OAuth 2.0 Authorization Framework reference link / References OAuth 2.0 client registration about / OAuth 2.0 client registration client types / Client types client identifier / Client identifier client authentication / Client authentication OAuth 2.0 grant types about / OAuth 2.0 grant types authorization code grant / Authorization code grant implicit grant / Implicit grant resource owner password credentials grant / Resource owner password credentials grant client credentials grant / Client credentials grant OAuth 2.0 protocol endpoints about / OAuth 2.0 protocol endpoints authorization endpoint / Authorization endpoint token endpoint / Token endpoint redirection endpoint / Redirection endpoint OAuth 2.0 roles about / OAuth 2.0 roles resource owner / Resource owner resource server / Resource server client / Client authorization server / Authorization server OAuth implementation Spring Security, using / OAuth implementation using Spring Security authorization code grant / Authorization code grant implicit grant / Implicit grant resource owner password credential grant / Resource owner password credential grant client credentials grant / Client credentials grant object-oriented programming (OOP) / Value objects restaurant service / OTRS overview user service / OTRS overview booking service / OTRS overview Open Source Software (OSS) / Microservices frameworks and tools OTRS overview / OTRS overview features, developing / Development of OTRS features OTRS features development about / Development of OTRS features home page/restaurant list page / Home page/restaurant list page Search Restaurants functionality / Search Restaurants restaurant details with reservation option / Restaurant details with reservation option login page / Login page reservation confirmation / Reservation confirmation P Performance Co-Pilot (PCP) / On-host performance monitoring – Vector Plain Old Java Object (POJO) / Sample REST program Postman Chrome extension used, for REST API testing / REST API testing using the Postman Chrome extension positive test scenarios / Some more positive test scenarios negative test scenarios / Negative test scenarios prerequisites, for bootstrapping app app module / Modules Angular library , loading / Modules App DOM configuration / Modules Q Quora reference link / Authentication and authorization R RabbitMQ reference link / References recipe types constant / Providers and services provider / Providers and services value / Providers and services factory / Providers and services service / Providers and services references / References, References, References Representational State Transfer (REST) / Writing the REST controller class download link / Summary restaurant details with reservation option about / Restaurant details with reservation option restaurant.html file / restaurant.html Restaurant µService about / Restaurant µService Controller class / Controller class Controller class, API versioning / API versioning service classes / Service classes repository classes / Repository classes entity classes / Entity classes REST Client extension for Chrome reference link / REST API testing using the Postman Chrome extension REST controller class writing / Writing the REST controller class @RestController / @RestController @RequestMapping / @RequestMapping @RequestParam / @RequestParam @PathVariable / @PathVariable RestTemplate / Client-side load balancing Ribbon / Service communication – Ribbon S sample domain service, domain-driven design (DDD) about / Sample domain service entity implementation / Entity implementation repository implementation / Repository implementation service implementation / Service implementation sample REST program about / Sample REST program REST controller class, writing / Writing the REST controller class app, executing / Making a sample REST app executable scopes $rootScope / Scopes $scope / Scopes Scumblr / Scumblr Search Providers / Scumblr Seed project reference link / Setting up the web app service-oriented architecture (SOA) / Evolution of µServices Service Oriented Architecture (SOA) / Best practices and principals Simian Army / Reliability monitoring service – Simian Army Simple Object Access Protocol (SOAP) / Evolution of µServices single page applications (SPAs) / UI-Router Spinnaker / Deployment and delivery – Spinnaker with Aminator SPR-9888 reference link / Spring Boot overview Spring Boot configuration / Spring Boot configuration overview / Spring Boot overview adding, to rest sample / Adding Spring Boot to the rest sample Jetty-embedded server, adding / Adding a Jetty-embedded server reference link / NetBeans IDE installation and setup, References configuration, reference link / NetBeans IDE installation and setup Spring Cloud reference link / References Spring Initializer reference link / Spring Boot overview Spring OAuth2 reference link / References Spring Security used, for OAuth implementation / OAuth implementation using Spring Security reference link / References Spring Tool Suite IDE reference link / NetBeans IDE installation and setup SSL enabling / Enabling Secure Socket Layer about / Enabling Secure Socket Layer strategic design and principles about / Strategic design and principles bounded context / Bounded context continuous integration / Continuous integration context map / Context map Subject Alternative Names (SAN) / Enabling Secure Socket Layer µService developing / Developing and implementing µServices implementing / Developing and implementing µServices entities / Developing and implementing µServices services / Developing and implementing µServices Repository object / Developing and implementing µServices Restaurant µService / Restaurant µService booking / Booking and user services user services / Booking and user services registration / Registration and Discovery service (Eureka service) discovery service (Eureka service) / Registration and Discovery service (Eureka service) Maven dependency / Registration and Discovery service (Eureka service) startup class / Registration and Discovery service (Eureka service) spring configurations / Registration and Discovery service (Eureka service) execution / Execution µServices evolution / Evolution of µServices monolithic architecture overview / Monolithic architecture overview used, for specifying limitations of monolithic architecture versus solution / Limitation of monolithic architecture versus its solution with µServices T Teamcity reference link / References Test Driven Development (TDD) / System/end-to-end test automation testing enabling / Testing Transport Security Layer (TSL) / Enabling Secure Socket Layer, OAuth 2.0 Turbine reference link / References Twitter URL / Enabling Secure Socket Layer, OAuth 2.0 specification – concise details U Unified Model Language (UML) / Ubiquitous language unique identity creating, for objects / Entities User Interface (UI) / Multilayered architecture V value objects (VOs) / Value objects virtual machines (VMs) / Deployment using a container such as Docker W web app setting up / Setting up the web app reference links / Setting up the web app willdurand/elk ELK Docker image reference link / References Z Zuul / Edge (proxy) server – Zuul .. .Mastering Microservices with Java Table of Contents Mastering Microservices with Java Credits About the Author About the Reviewer www.PacktPub.com... Maintaining different versions Let's explore more References Summary Index Mastering Microservices with Java Mastering Microservices with Java Copyright © 2016 Packt Publishing All rights reserved No part... also grasp the knowledge of microservices testing using REST Java clients and other tools Chapter 6, Securing Microservices, explains how to secure microservices with respect to authentication