![]()
Table of Contents
Spring Microservices
Credits
About the Author
Acknowledgments
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
1. Demystifying Microservices
The evolution of microservices
Business demand as a catalyst for microservices evolution
Technology as a catalyst for the microservices evolution
Imperative architecture evolution
What are microservices?
Microservices – the honeycomb analogy
Principles of microservices
Single responsibility per service
Microservices are autonomous
Characteristics of microservices
Services are first-class citizens
Characteristics of services in a microservice
Microservices are lightweight
Microservices with polyglot architecture
Automation in a microservices environment
Microservices with a supporting ecosystem
Microservices are distributed and dynamic
Antifragility, fail fast, and self-healing
Microservices examples
An example of a holiday portal
A microservice-based order management system
An example of a travel agent portal
Microservices benefits
Supports polyglot architecture
Enabling experimentation and innovation
Elastically and selectively scalable
Allowing substitution
Enabling to build organic systems
Helping reducing technology debt
Allowing the coexistence of different versions
Supporting the building of self-organizing systems
Supporting event-driven architecture
Enabling DevOps
Relationship with other architecture styles
Relations with SOA
Service-oriented integration
Legacy modernization
Service-oriented application
Monolithic migration using SOA
Relations with Twelve-Factor apps
A single code base
Bundling dependencies
Externalizing configurations
Backing services are addressable
Isolation between build, release, and run
Stateless, shared nothing processes
Exposing services through port bindings
Concurrency to scale out
Disposability with minimal overhead
Development and production parity
Externalizing logs
Package admin processes
Microservice use cases
Microservices early adopters
The common theme is monolithic migrations
Summary
2. Building Microservices with Spring Boot
Setting up a development environment
Developing a RESTful service – the legacy approach
Moving from traditional web applications to microservices
Using Spring Boot to build RESTful microservices
Getting started with Spring Boot
Developing the Spring Boot microservice using the CLI
Developing the Spring Boot Java microservice using STS
Examining the POM file
Examining Application.java
Examining application.properties
Examining ApplicationTests.java
Testing the Spring Boot microservice
Developing the Spring Boot microservice using Spring Initializr – the HATEOAS example
What's next?
The Spring Boot configuration
Understanding the Spring Boot autoconfiguration
Overriding default configuration values
Changing the location of the configuration file
Reading custom properties
Using a .yaml file for configuration
Using multiple configuration profiles
Other options to read properties
Changing the default embedded web server
Implementing Spring Boot security
Securing microservices with basic security
Securing a microservice with OAuth2
Enabling cross-origin access for microservices
Implementing Spring Boot messaging
Developing a comprehensive microservice example
Spring Boot actuators
Monitoring using JConsole
Monitoring using SSH
Configuring application information
Adding a custom health module
Building custom metrics
Documenting microservices
Summary
3. Applying Microservices Concepts
Patterns and common design decisions
Establishing appropriate microservice boundaries
Autonomous functions
Size of a deployable unit
Most appropriate function or subdomain
Polyglot architecture
Selective scaling
Small, agile teams
Single responsibility
Replicability or changeability
Coupling and cohesion
Think microservice as a product
Designing communication styles
Synchronous style communication
Asynchronous style communication
How to decide which style to choose?
Orchestration of microservices
How many endpoints in a microservice?
One microservice per VM or multiple?
Rules engine – shared or embedded?
Role of BPM and workflows
Can microservices share data stores?
Setting up transaction boundaries
Altering use cases to simplify transactional requirements
Distributed transaction scenarios
Service endpoint design consideration
Contract design
Protocol selection
Message-oriented services
HTTP and REST endpoints
Optimized communication protocols
API documentations
Handling shared libraries
User interfaces in microservices
Use of API gateways in microservices
Use of ESB and iPaaS with microservices
Service versioning considerations
Design for cross origin
Handling shared reference data
Microservices and bulk operations
Microservices challenges
Data islands
Logging and monitoring
Dependency management
Organization culture
Governance challenges
Operation overheads
Testing microservices
Infrastructure provisioning
The microservices capability model
Core capabilities
Infrastructure capabilities
Supporting capabilities
Process and governance capabilities
Summary
4. Microservices Evolution – A Case Study
Reviewing the microservices capability model
Understanding the PSS application
Business process view
Functional view
Architectural view
Design view
Implementation view
Deployment view
Death of the monolith
Pain points
Stop gap fix
Retrospection
Shared data
Single database
Native queries
Stored procedures
Domain boundaries
Microservices to the rescue
The business case
Plan the evolution
Evolutionary approach
Identification of microservices boundaries
Analyze dependencies
Events as opposed to query
Events as opposed to synchronous updates
Challenge requirements
Challenge service boundaries
Final dependency graph
Prioritizing microservices for migration
Data synchronization during migration
Managing reference data
User interfaces and web applications
Session handling and security
Test strategy
Building ecosystem capabilities
Migrate modules only if required
Target architecture
Internal layering of microservices
Orchestrating microservices
Integration with other systems
Managing shared libraries
Handling exceptions
Target implementation view
Implementation projects
Running and testing the project
Summary
5. Scaling Microservices with Spring Cloud
Reviewing microservices capabilities
Reviewing BrownField's PSS implementation
What is Spring Cloud?
Spring Cloud releases
Components of Spring Cloud
Spring Cloud and Netflix OSS
Setting up the envi...