Adam L. Davis
Oviedo, FL, USA
Any source code or other supplementary material referenced by the author in this book is available to readers on GitHub via the books product page, located at www.apress.com/9781484241752 . For more detailed information, please visit http://www.apress.com/source-code .
ISBN 978-1-4842-4175-2 e-ISBN 978-1-4842-4176-9
https://doi.org/10.1007/978-1-4842-4176-9
Library of Congress Control Number: 2018965180
Adam L. Davis 2019
This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed.
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of publication, neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or omissions that may be made. The publisher makes no warranty, express or implied, with respect to the material contained herein.
Distributed to the book trade worldwide by Springer Science+Business Media New York, 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@springer-sbm.com, or visit www.springeronline.com. Apress Media, LLC is a California LLC and the sole member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation.
Preface
Who Is the Target Audience?
This book is intended for Java developers of beginning or intermediate skill who wish to learn more about reactive programming. If you are still reading this, then that probably means you!
Why You Should Read This Book
You should read this book to learn the basic of reactive programming with Reactive Streams and understand what they are good for, when they should be used, and the principles behind them. This book uses straightforward examples and introduces concepts gradually so as not to overwhelm the reader. It will refer to existing models of concurrency from time to time only as reference points and will not assume any advanced knowledge on the topic.
After reading this book, you should have a firm understanding of Reactive Streams, including three different implementations, and how to integrate them into real software projects. You will understand when to use Reactive Streams, how to write tests, and how to build a whole project.
What Is Not in This Book
This book assumes you have a basic background of programming in Java, so it will not cover the basics.
For more of an introduction on basic Java concepts, please check out my other books: Modern Programming Made Easy, Modern Java, and Whats New in Java 8 .
Table of Contents
About the Author and About the Technical Reviewer
About the Author
Adam L. Davis
(@adamldavis ) makes software. Hes spent many years developing in Java (since Java 1.2) and has enjoyed using Spring and Hibernate. Since 2006 hes been using Groovy and Grails in addition to Java to create SaaS web applications that help track finances for large institutions (among other things). Adam has a masters and a bachelors degree in computer science from Georgia Tech. For more, visit http://adamldavis.com .
About the Technical Reviewer
Manuel Jordan Elera
is an autodidactic developer and researcher who enjoys learning new technologies for his own experiments and creating new integrations. Manuel won the Springy Award Community Champion and Spring Champion 2013. In his little free time, he reads the Bible and composes music on his guitar. Manuel is known as dr_pompeii. He has tech reviewed numerous books for Apress, including Pro Spring, 4th Edition (2014); Practical Spring LDAP (2013); Pro JPA 2, Second Edition (2013); and Pro Spring Security (2013). Read his 13 detailed tutorials about many Spring technologies, contact him through his blog at www.manueljordanelera.blogspot.com , and follow him on his Twitter account, @dr_pompeii .
Adam L. Davis 2019
Adam L. Davis Reactive Streams in Java https://doi.org/10.1007/978-1-4842-4176-9_1
1. Introduction to Reactive Streams
Reactive Streams is an initiative to provide a standard for asynchronous stream processing with non-blocking back pressure. This encompasses efforts aimed at runtime environments (JVM and JavaScript) as well as network protocols.
reactive-streams.org
At their core, Reactive Streams are an effort to provide highly responsive applications able to handle many requests per second with the ability to manage backpressure (the ability to skip or queue data that is coming too fast to be processed). Asynchronous means processing can take place in many threads, without stopping to read data from a file or a web request for example. Although many implementations already exist for asynchronous processing, such as Javas Future, CompletableFuture, and parallel streams, most of them do not have standard support for asynchronous handling of backpressure.
Reactive Streams are a unifying standard that abstracts existing methods of concurrency. Also, by having one standard, different Reactive Streams implementations can interoperate in one application.
Java 9+
Java 9 was an important release of Java and includes Project Jigsaw which represents a huge restructuring of the core JDK (Java Development Kit ) as well as a new and improved way of defining code dependencies. This provides compile-time errors when dependencies are missing as opposed to runtime errors, which is a vast improvement for software development efficiency. Java 9 also introduced a unified interface for Reactive Streams.