Microservices for Java Architects:
Addendum for the Java EE Architects Handbook
By Derek C. Ashmore
2016 by Derek C. Ashmore. All rights reserved.
Editor: Cathy Reed
Cover Design: The Roberts Group
Interior Design: The Roberts Group
Published by:
DVT Press
Bolingbrook, IL
sales@dvtpress.com
http://www.dvtpress.com
All rights reserved. No part of this book may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording or by any information storage and retrieval system, without written permission from the author, except for the inclusion of brief quotations for a review.
The opinions and views expressed in this book are solely that of the author. This book does not necessarily represent the opinions and views of the technical reviewers or the firms that employ them.
TRADEMARKS: Java, Java EE, Java Development Kit are trademarks of Oracle Corporation, Inc. All other products or services mentioned in this book are the trademarks or service marks of their respective companies and organizations.
While every precaution has been taken in the preparation of this book, the author and publisher assume no responsibility for errors and omissions or for damages resulting from the use of the information contained herein.
Table of Contents
Preface
Readers of the Java EE Architects Handbook, Second Edition are well acquainted with traditional application architectures. Since this book was published, microservices architecture has emerged. It is an important architecture with a variety of uses that Java architects should understand and be able to use.
This book details microservices architecture and is an addendum to the Java EE Architects Handbook , Second Edition. This book will define microservices architecture and provide an overview of costs and benefits. As with the Architects Handbook, Ill go on to address architecture, design, and implementation concerns specific to microservices architecture.
This book will take the reader to the point of producing a microservice. Beyond that deployable, theres the very interesting world of DevOps that addresses how to deploy, manage, and cluster that microservice and connect it to the resources it needs to function. While this is a very interesting world and one that I encourage you to take an interest in, it is out of scope for this book.
How this book is organized
The first chapter defines microservices architecture and contrasts it with a layered web application architecture described in the Java EE Architects Handbook . Ill summarize the benefits and costs of using microservices architecture. Ill also discuss similarities and differences between microservices and service oriented architectures (SOA).
The second chapter dives into design considerations for microservices. All new paradigms have coding patterns, and microservices architecture is no exception. Ill detail coding patterns to enhance performance and to increase resiliency to service failure. Ill also discuss how to make microservices easier to support.
The third chapter discusses cross-cutting concerns for microservices and various ways of incorporating them into services written in Java. Ill discuss easy ways to package and deploy microservices as well as to instrument them for health checks and performance measurement.
The fourth chapter discusses when using microservices architecture is appropriate. I also identify current marketing hype surrounding microservices architecture and the fine print required to reap the benefits from it. Were going to find out that microservices architecture is not a silver bullet and nor should it be used for all applications.
The fifth chapter discusses various topics needed to effectively manage a large number of microservices. Much has been written about how microservices architecture changes the way we design and develop applications; but very little has been written on effectively managing large numbers of microservices. As application architects, we advise management and we need to help guide them through the transition to managing microservices architecture.
Description of common resources
This book often makes references to the following open-source projects that are frequently used with many Java EE applications:
- Apache HttpClient ( https://hc.apache.org/ )
- Apache CXF ( https://cxf.apache.org/ )
- Docker ( https://www.docker.com/ )
- Spring Boot ( http://projects.spring.io/spring-boot/ )
- Dropwizard ( http://www.dropwizard.io/ )
- Hysterix { https://github.com/Netflix/Hystrix }
- SoapUI ( http://www.soapui.org/ )
- Google Guava Core Libraries ( https://code.google.com/p/guava-libraries/ )
- Apache Commons Lang ( http://commons.apache.org/lang/ )
- My GitHub ( https://github.com/Derek-Ashmore )
Another open-source project on which this book relies is Moneta , which is an open-source example of a microservice written in Java. Moneta illustrates several of the concepts discussed in the book.
Feedback
Im always interested in reading comments and suggestions that will improve future editions of this book. Please send feedback directly to me at .
About the Author
Derek Ashmore is a senior technology expert with over 25 years of experiences in a wide variety of technologies and industries. His past roles include Application Architect, Cloud Architect, Project Manager, Application Developer, and Database Administrator. He has extensive experience with custom application development as well as integrating applications with commercial products such as Great Plains, Salesforce, Microsoft Dynamics, DocuSign, and others. Derek has been designing and leading Java-related projects since 1999.
Derek is also the author of the The Java EE Architects Handbook, Second Edition , which is also available from DVT Press.
If you need a project assessment for your Java-related project, Derek can be retained by contacting .
Derek can be contacted the following ways:
- Email:
- LinkedIn: http://www.linkedin.com/in/derekashmore
- Facebook: https://www.facebook.com/JavaEEArchitectHandbook
- Twitter: https://twitter.com/Derek_Ashmore
Acknowledgments
This book could not have been written without a large amount of assistance. Several colleagues helped tremendously to refine the book concept and edit the drafts, thus keeping me from mass marketing mediocrity. They have my undying gratitude. I could not have written the book without the assistance of the following people: Budi Kurniawan , David Arthurs , David Greenfield , James Gibbings , Ken Liu, Michael Spicuzza , Peeyush Maharshi , Pradeep Sadhu , Rick Miller , Scott Kramer , Scott Wheeler , and Silvio de Morais .
Many thanks to my editor, Cathy Reed, who painstakingly corrected my numerous grammar mistakes and graciously pointed out places where my verbiage was less than clear. Many thanks to Sherry and Tony Roberts and their colleagues at the Roberts Group for fantastic cover art, typesetting, indexing, and general wizardry to make the book aesthetically pleasing.
Many thanks to my wife Beth and my children Zachary and Morgan. They routinely put up with music coming out of the office at all hours of the night while I was working on this, and Beth routinely watched our children so that I could devote time to writing this.
I retain responsibility for any errors that remain.
Chapter 1: Microservices Defined
The microservices architecture doesnt have a concrete definition. Microservices architecture organizes applications as a suite of discrete, independent services. Usually, these web services adopt a RESTful style. Any coupling between services is restricted to the service layer, with no coupling at a code or database level. The approach does have some similarities to the Service Oriented Architecture (SOA) approach, which will be discussed later. We define it as a series of common traits that microservices have.
Next page