Reactive Design Patterns
Roland Kuhn with Brian Hanafee and Jamie Allen
![Reactive Design Patterns - image 1](/uploads/posts/book/288177/logo.jpg)
Copyright
For online information and ordering of this and other Manning books, please visit www.manning.com. The publisher offers discounts on this book when ordered in quantity. For more information, please contact
Special Sales Department Manning Publications Co. 20 Baldwin Road PO Box 761 Shelter Island, NY 11964 Email:
orders@manning.com2017 by Manning Publications Co. All rights reserved.
No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by means electronic, mechanical, photocopying, or otherwise, without prior written permission of the publisher.
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in the book, and Manning Publications was aware of a trademark claim, the designations have been printed in initial caps or all caps.
Recognizing the importance of preserving what has been written, it is Mannings policy to have the books we publish printed on acid-free paper, and we exert our best efforts to that end. Recognizing also our responsibility to conserve the resources of our planet, Manning books are printed on paper that is at least 15 percent recycled and processed without the use of elemental chlorine.
![Picture 3](/uploads/posts/book/288177/common01.jpg) | Manning Publications Co.20 Baldwin RoadPO Box 761Shelter Island, NY 11964 |
Development editor: Jennifer StoutTechnical development editor: Brian HanafeeProject editors: Tiffany Taylor and Janet VailLine editor: Ben KovitzCopyeditor: Tiffany TaylorProofreader: Katie TennantTechnical proofreader: Thomas LockneyTypesetter: Dottie MarsicoCover designer: Leslie Haimes
ISBN 9781617291807
Printed in the United States of America
1 2 3 4 5 6 70 8 9 10 EBM 22 21 20 19 18 17
Dedication
To my children
Roland
Brief Table of Contents
Table of Contents
Foreword
Im grateful that Roland has taken the time to write this foundational book, and I cant think of anyone more capable of pulling it off. Roland is an unusually clear and deep thinker; he coauthored the Reactive Manifesto, has been the technical lead for the Akka project for several years, has coauthored and taught the very popular Coursera course on Reactive programming and design, and is the best technical writer I have met.
Clearly, Im very excited about this book. It outlines what Reactive architecture/design is all about, and does an excellent job explaining it from first principles in a practical context. Additionally, it is a catalog of patterns that explains the bigger picture, how to think about system design, and how it is all connectedmuch like what Martin Fowlers Patterns of Enterprise Application Architecture did 15 years ago.
During my professional life, I have seen the immense benefits of resilient, loosely coupled, message-driven systems firsthand, especially when compared with more--traditional approaches that propose to hide the nature of distributed systems. In 2013, I had the idea of formalizing the experiences and lessons learned: the Reactive Manifesto was born. It started out as a set of rough notes that I remember presenting to the company at one of Typesafes (now Lightbend) internal technical meetups. Coincidentally, this meetup was collocated with the Scala Days New York conference, where Roland, Martin Odersky, and Erik Meijer shot their bad, and unintentionally quite funny, promotion video of their Coursera course on Reactive programming. The story around the Reactive principles resonated with the other engineers and was published in July of 2013. Since then, the Manifesto has been receiving a lot of great feedback from the community. It was rewritten and vastly improved by Roland, Martin Thompson, Dave Farley, and myself, leading up to version 2.0 published in September 2014. By the end of 2016, it had been signed by more than 17,000 people. During this time, we have seen Reactive progress from a virtually unacknowledged technique used only by fringe projects within a select few corporations to a part of the overall platform strategy of numerous big players in many different fields, including middleware, financial services, retail, social media, betting/gaming, and so on.
The Reactive Manifesto defines Reactive Systems as a set of architectural design principles that are geared toward meeting the demands that systems facetoday and tomorrow. These principles are most definitely not new; they can be traced back to the 70s and 80s and the seminal work by Jim Gray and Pat Helland on the Tandem System, as well as Joe Armstrong and Robert Virding on Erlang. However, these pioneers were ahead of their time, and it was not until the past five years that the technology industry was forced to rethink current best practices for enterprise system development and learned to apply the hard-won knowledge of the Reactive principles to todays world of multicore architectures, Cloud Computing, and the Internet of Things.
By now, the Reactive principles have had a big impact on the industry, and as with many successful ideas, they get overloaded and reinterpreted. This is not a bad thing; ideas need to evolve to stay relevant. However, this can also cause confusion and lead to dilution of the original intent. One example is the unfortunate emerging misconception that Reactive is nothing but programming in an asynchronous and nonblocking style using callbacks or stream-oriented combinatorstechniques that are aptly classified as Reactive Programming. Concentrating on this aspect alone means missing out on many of the benefits of the Reactive principles. It is the contribution of this book to take a much larger perspectivea systems viewmoving the focus from how individual components function in isolation to the design of collaborative, resilient, and elastic systems: Reactive systems.
This future classic belongs on the shelf of every professional programmer, right next to GoF[] Enjoy the rideI certainly did!
Design Patterns: Elements of Reusable Object-Oriented Software by Gamma, Helm, Johnson, and Vlissides (Addison-Wesley, 1995).
Domain-Driven Design by Eric Evans (Addison-Wesley, 2004).
J SONAS B ONR
CTO AND F OUNDER OF L IGHTBEND
C REATOR OF A KKA
Preface
Even before I had officially joined the Akka team, Mike Stephens from Manning tried to convince me to write a book on Akka. I was tempted to say yes, but in the context of an impending change of jobs and countries, my wife brought me to my senses: such a project would be too much to handle. The idea of writing a book stuck in my head, though. Three years laterafter the Reactive Manifesto had been publishedMartin Odersky, Erik Meijer, and I taught the course Principles of Reactive Programming on the Coursera platform, reaching more than 120,000 students in two iterations. The idea for that course had been born at a Typesafe engineering meeting where I suggested to Martin that we should nurture the blossoming movement of Reactive programming by demonstrating how to use these tools effectively while avoiding the pitfallsmy own experience answering questions on the Akka mailing list had given me a good idea of the topics people commonly struggled with.
A video course is a wonderful way of reaching a large number of students, interacting with them on the discussion forums, and in general improving the lives of others. Unfortunately, the discussion of the subject is necessarily limited in its depth and breadth by the format: only so much can be shown in seven weekly lectures. Therefore, I still longed for formalizing and passing on my knowledge about Reactive systems by writing a book. It would have been straightforward to write about Akka, but I felt that if I wrote a book, its scope should be wider than that. I love working on Akkait has literally changed the course of my lifebut Akka is merely a tool for expressing distributed and highly reliable systems, and it is not the only tool needed in this regard.