Microservice Patterns
Chris Richardson
  • MEAP began February 2017
  • Publication in November 2017 (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. 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. Architecture to the rescue

1.3. The microservice architecture

1.3.1. Scale cube and microservices

1.3.2. FTGO microservice architecture

1.3.3. Isn't the microservice architecture the same as SOA?

1.4. Benefits of microservices

1.5. Drawbacks of microservices

1.6. Microservice architecture pattern language

1.6.1. Microservices are not a silver bullet

1.6.2. What is a pattern?

1.6.3. Overview of the Microservice architecture pattern language

1.6.4. Testing patterns

1.7. Beyond microservices: process and organization

1.7.1. Organization

1.7.2. Process

1.8. The human side of adopting microservices

1.9. 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 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. If only it were this easy…​

2.3.3. Decompose by sub-domain/bounded context

2.3.4. 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.2.3. Synchronous Remote Procedure Invocation

3.2.4. Asynchronous, message-based communication

3.3. Transactional messaging with the Tarr framework

3.3.1. Use a database table as a message queue

3.3.2. Transactional messaging framework (TARR).

3.4. Using asynchronous messaging to improve availability

3.4.1. Synchronous communication reduces availability

3.4.2. Eliminating synchronous interaction

3.5. Summary

4. Managing transactions with sagas

4.1. Transaction management in a microservice architecture

4.1.1. The trouble with distributed transactions

4.1.2. Using sagas to maintain data consistency

4.2. Orchestrating sagas

4.2.1. Saga coordinators are state machines

4.2.2. Saga coordinators exchange messages with saga participants

4.2.3. Saga coordinators subscribe to events

4.2.4. Transactional saga coordination and messaging

4.3. Designing business logic with sagas

4.3.1. Explicit vs. implicit saga coordinator

4.3.2. Domain objects have additional states

4.3.3. Sagas are interwoven

4.3.4. Using compensating transactions to rollback changes

4.4. Order Service design

4.4.1. About the saga framework

4.4.2. Create order saga coordinator design

4.5. Sagas and the FTGO architecture

4.6. 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 management 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. 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. Benefits of event sourcing

6.1.8. Drawbacks of event sourcing

6.2. Evolving domain events

6.2.1. Event schema evolution

6.2.2. Managing schema changes through upcasting

6.3. Implementing an event store

6.3.1. How Eventuate Local works

6.3.2. The Eventuate client framework for Java

6.4. Implementing saga participants with event sourcing

6.4.1. Implementing a saga participant with an RDBMS-based event store

6.4.2. NoSQL—​based Event store saga participants

6.4.3. Example event sourcing-based saga participant

6.5. Implementing saga orchestrators with event sourcing

6.5.1. Using an event sourcing-based implicit saga orchestrator

6.5.2. Implementing an Explicit Saga orchestrators using event sourcing

6.5.3. The event sourcing version of the CreateOrder saga

6.6. 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.
Buy
MEAP combo $49.99 pBook + eBook + liveBook
MEAP eBook $39.99 pdf + ePub + kindle + liveBook

FREE domestic shipping on three or more pBooks