Microservice Patterns
Chris Richardson
  • MEAP began February 2017
  • Publication in Spring 2018 (estimated)
  • ISBN 9781617294549
  • 375 pages (estimated)
  • printed in black & white

The monolithic architecture works well for small, simple applications. However, successful applications have a habit of growing. Eventually the development team ends up in what is known as monolithic hell. All aspects of software development and deployment become painfully slow. The solution is to adopt the microservice architecture, which structures an application as a services, organized around business capabilities. This architecture accelerates software development and enables continuous delivery and deployment of complex software applications.

Microservice Patterns teaches enterprise developers and architects how to build applications with the microservice architecture. Rather than simply advocating for the use the microservice architecture, this clearly-written guide takes a balanced, pragmatic approach. You'll discover that the microservice architecture is not a silver bullet and has both benefits and drawbacks. Along the way, you'll learn a pattern language that will enable you to solve the issues that arise when using the microservice architecture. This book also teaches you how to refactor a monolithic application to a microservice architecture.

"As a senior software engineer working on a very large learning management system I've found Microservice Patterns and your website (http://microservices.io/) to be invaluable in modernizing our architecture.."

~ John I. McSwain, III

Table of Contents detailed table of contents

1. Escaping monolithic hell

1.1. About FTGO

1.1.1. What the FTGO application does

1.1.2. The FTGO architecture

1.1.3. The benefits of the monolithic architecture

1.1.4. Monolithic hell

1.1.5. Overwhelming complexity intimidates developers

1.1.6. Slow day to day development

1.1.7. An obstacle to agile development and deployment

1.1.8. Scaling the application can be challenging

1.1.9. Reliability

1.1.10. Requires long-term commitment to a technology stack

1.2. The microservice architecture to the rescue

1.2.1. Scale cube and microservices

1.2.2. Microservices as a form of modularity

1.2.3. Each service has its own database

1.2.4. The FTGO microservice architecture

1.2.5. Isn’t the microservice architecture the same as SOA?

1.3. Benefits and drawbacks of the microservice architecture

1.3.1. Benefits of the microservice architecture

1.3.2. The drawbacks of the microservice architecture

1.4. The microservice architecture pattern language

1.4.1. Microservices are not a silver bullet

1.4.2. What is a pattern?

1.4.3. Overview of the Microservice architecture pattern language

1.5. Beyond microservices: process and organization

1.5.1. Software development and delivery organization

1.5.2. Software development and delivery process

1.5.3. The human side of adopting microservices

1.6. Summary

2. Decomposition strategies

2.1. The purpose of architecture

2.1.1. Why architecture matters

2.1.2. The microservice architecture is an architectural style

2.1.3. Defining an application’s microservice architecture

2.2. Identifying the system operations

2.2.1. Creating a high-level domain model

2.2.2. Defining system operations

2.3. Strategies for decomposing an application into services

2.3.1. Decompose by business capability

2.3.2. Using scenarios to determine how the service collaborate

2.3.3. If only it were this easy�

2.3.4. Decompose by sub-domain/bounded context

2.3.5. Decomposition guidelines

2.4. Summary

3. Inter-process communication in a microservice architecture

3.1. API design in a microservice architecture

3.1.1. Defining APIs in a microservice architecture

3.1.2. Evolving APIs

3.2. About inter-process communication mechanisms

3.2.1. Interaction styles

3.2.2. Message formats

3.3. Remote Procedure Invocation (RPI)

3.3.1. Using REST

3.3.2. Using gRPC

3.3.3. Handling partial failure

3.3.4. Using service discovery

3.4. Asynchronous, message-based communication

3.4.1. Overview of messaging

3.4.2. Message brokers

3.4.3. Implementing request/reply

3.4.4. Competing consumers

3.4.5. Handling duplicate messages

3.4.6. Transactional messaging

3.4.7. Defining messaging APIs

3.4.8. Benefits and drawbacks of messaging

3.5. Transactional messaging with the Tram framework

3.5.1. Use a database table as a message queue

3.5.2. Transactional messaging using the Tram framework

3.6. Using asynchronous messaging to improve availability

3.6.1. Synchronous communication reduces availability

3.6.2. Eliminating synchronous interaction

3.7. Summary

4. Managing transactions with sagas

4.1. Transaction management in a microservice architecture

4.1.1. The need for 'distributed transactions' in a microservice architecture

4.1.2. The trouble with distributed transactions

4.1.3. Using sagas to maintain data consistency

4.2. Designing a saga’s sequencing logic

4.2.1. Choreography-based sagas

4.2.2. Orchestration-based sagas

4.3. The impact of sagas on business logic

4.3.1. Sagas uses compensating transactions to rollback changes

4.3.2. Sagas are interwoven

4.4. The design of the Order Service and its sagas

4.4.1. About the Tram saga framework

4.4.2. The OrderService class

4.4.3. The design of the CreateOrderSaga orchestrator

4.4.4. The OrderCommandHandlers class

4.4.5. The OrderServiceConfiguration class

4.5. Summary

5. Designing business logic in a microservice architecture

5.1. Business logic organization patterns

5.1.1. Transaction script pattern

5.1.2. Domain Model pattern

5.1.3. About DDD

5.2. Using DDD aggregates

5.2.1. The problem with fuzzy boundaries

5.2.2. Aggregates have explicit boundaries

5.2.3. Aggregate rules

5.2.4. Aggregate granularity

5.2.5. Designing business logic with aggregates

5.3. Publishing domain events

5.3.1. Why publish change events?

5.3.2. What is a domain event

5.3.3. Event enrichment

5.3.4. Identifying domain events

5.3.5. Generating and publishing domain events

5.3.6. Consuming domain events

5.4. Restaurant order management business logic

5.4.1. The RestaurantOrder aggregate

5.5. Order service business logic

5.5.1. The Order Aggregate

5.5.2. The OrderService service class

5.6. Summary

6. Developing business logic with event sourcing

6.1. Developing business logic using event sourcing

6.1.1. The trouble with traditional persistence

6.1.2. Overview of event sourcing

6.1.3. Handling concurrent updates using optimistic locking

6.1.4. Event sourcing and publishing events

6.1.5. Using snapshots to improve performance

6.1.6. Idempotent message processing

6.1.7. Evolving domain events

6.1.8. Benefits of event sourcing

6.1.9. Drawbacks of event sourcing

6.2. Implementing an event store

6.2.1. How Eventuate Local works

6.2.2. The Eventuate client framework for Java

6.3. Using sagas and event sourcing together

6.3.1. Implementing choreography-based sagas using event sourcing

6.3.2. Creating an orchestration-based saga

6.3.3. Implementing an event sourcing-based saga participant

6.3.4. Implementing saga orchestrators using event sourcing

6.4. Summary

7. Implementing queries in a microservice architecture

8. External API patterns

9. Testing microservices

10. Microservices in production

11. Refactoring to microservices

What's inside

  • Understanding the microservice architecture
  • When and when not to use the microservice architecture
  • How to develop a microservice architecture for an application
  • Transaction management and querying in a microservice architecture
  • Effective testing strategies for microservices
  • How to refactor a monolithic application into services

About the reader

Readers should be familiar with the basics of enterprise application architecture, design, and implementation.

About the author

Chris Richardson is a developer and architect. He is a Java Champion, a JavaOne rock star and the author of POJOs in Action, which describes how to build enterprise Java applications with frameworks such as Spring and Hibernate. Chris was also the founder of the original CloudFoundry.com, an early Java PaaS for Amazon EC2. Today, he is a recognized thought leader in microservices. Chris is the creator of http://microservices.io , a website describing how to develop and deploy microservices. He provides microservices consulting and training and is working on his third startup http://eventuate.io , an application platform for developing microservices.

Manning Early Access Program (MEAP) Read chapters as they are written, get the finished eBook as soon as it’s ready, and receive the pBook long before it's in bookstores.
MEAP combo $49.99 pBook + eBook + liveBook
MEAP eBook $39.99 pdf + ePub + kindle + liveBook

FREE domestic shipping on three or more pBooks