1. Trang chủ
  2. » Công Nghệ Thông Tin

Reactive programming with java 9

585 185 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Cấu trúc

  • Preface

    • What this book covers

    • What you need for this book

    • Who this book is for

    • Conventions

    • Reader feedback

    • Customer support

      • Downloading the example code

      • Errata

      • Piracy

      • Questions

  • Introduction to Reactive Programming

    • Asynchronous programming

      • Concurrency

      • Parallel programming

      • Streams

        • Features of Streams

          • The sequential elements

          • Source of a stream

          • Performing operations

          • Performing automatic operations

      • Reactive Streams

        • What do Reactive Streams address?

          • Asynchronicity

          • Back pressure

      • Reactive Programming

      • Reactive Manifesto

        • Responsiveness

        • Resilience

        • Elastic

        • Message-driven

        • Scalable

        • Benefits of Reactive Programming

      • Reactive Extensions

        • RxJava

          • Advantages of RxJava

        • Project Reactor

          • The features of Project Reactor

        • Akka Streams

          • Actor

        • Ratpack

          • Aim of Ratpack

        • Quasar

        • MongoDB

        • Slick

        • Vert.x

          • The components of Vert.x

      • Reactive Streams in Java 9

        • The Technology Compatibility Kit (TCK)

        • API components

      • Reactive in and across JVM

        • ThreadPoolExecutor

        • ScheduledThreadPoolExecutor

      • The Fork/Join framework

    • Summary

  • Programming Paradigm Shift

    • Programming paradigm

      • Imperative programming

      • Procedural programming

        • Avoiding bugs

    • Functional programming

      • Need for functional programming

        • Concurrency

      • Functional programming in JVM

        • Functional interface

      • Lambda expressions

        • Advantages of using lambda expressions

        • Functional interfaces provided by JDK 8

          • Method reference

          • Streams API

        • Characteristics of functional programming

    • Declarative programming

      • Characteristics of declarative programming

      • Advantages of declarative programming

    • Operator fusion

      • Macro fusion

      • Micro fusion

    • Summary

  • Reactive Streams

    • Discussing the Collection framework

      • Streams in action

      • Delving into the Flow API

        • The building blocks

          • Publisher

          • The SubmissionPublisher class

          • Subscriber

        • The Subscription interface

        • The behavior of the Publisher-Subscriber system

        • Processor

        • The behavior of the Publisher-Processor-Subscriber system

      • Designing nonblocking interfaces

    • Understanding backpressure

    • Summary

  • Reactive Types in RxJava

    • ReactiveX

    • Observer design pattern

    • The Iterator design pattern

      • Advantages of ReactiveX

    • RxJava

      • Observable Streams

      • Components of RxJava

        • Observable

        • Observer

        • Subscriber

    • Hot or cold Observables

    • Creating Observable emitting sequential data

      • Using the just() operator

      • Using the defer() operator

      • Using the empty() operator

      • Using the never() operator

      • Using the error() operator

      • Using the create() operator

    • Transforming Rx non-compatible sequences into Observables

      • Conversion using the from() operator

    • Creating Observables for unrestricted infinite length

      • The interval() operator

      • The range() operator

      • The timer() operator

    • Types of observables

      • The Observable<T> operator

        • Scenarios for using an Observable

      • The Single<T> operator

      • The Flowable<T> operator

        • Scenarios to use Flowable

      • The Maybe<T> operator

      • Completable

    • Understanding the Disposable interface

      • Disposable Subscribers

        • The DefaultSubscriber class

        • DisposableSubscriber

        • The ResourceSubscriber interface

        • CompositeDisposable

    • Subject

      • Flavors of Subject

        • The AsyncSubject class

        • The BehaviorSubject class

        • ReplaySubject

        • PublishSubject

    • Summary

  • Operators

    • Demystifying RxMarbles using an Observable

    • Transforming Observables using operators

      • Using the buffer() operator

      • Using the flatMap() operator

      • Using the groupBy() operator

      • Using the map() operator

      • Using the scan() operator

      • Using the window() operator

    • Filtering Observable

      • Using the debounce() operator

      • Using the distinct() operator

        • Using the distinctUntilChanged() operator

      • Using the elementAt() operator

      • Using the filter() operator

      • Using the first(), never(), and empty() operators

      • Using the last() operator

      • Using the ignoreElements() operator

      • Using the sample() operator

      • Using the skip() operator

      • Using the skipLast() operator

      • Using the take() operator

      • Using the takeLast() operator

    • Combining Observables

      • Using the merge() operator for combining observables

      • Using the combineLatest() operator

      • Using the startWith() operator

      • Using the and(), then(), and when() operators

      • Using the switchIfEmpty() operator

      • Using the zip() operator

      • Using the join() operator

    • Conditional operators

      • Using the all() operator

      • Using the amb() operator

      • Using the contains() operator

      • Using the defaultIfEmpty() operator

      • Using the sequenceEqual() operator

      • Using the takeWhile() operator

    • The mathematical and aggregate operators

      • Using the average() operator

      • Using the concat() operator

      • Using the count() operator

      • Using the max() operator

      • Using the min() operator

      • Using the reduce() operator

      • Using the sum() operator

    • Summary

  • Building Responsiveness

    • Concurrency

      • Comparing asynchronicity with concurrency

    • Scheduling

      • Scheduler

        • The subscribeOn() operator

        • The observeOn() operator

      • Schedulers

        • The computation() method

        • The from() operator

        • Th io() operator

        • The single() operator

        • The newThread() operator

        • The trampoline() operator

      • Operators and thread safety

        • Operators are not thread safe

          • The serialize() operator

    • Latency

    • Summary

  • Building Resiliency

    • Resilience

      • Reliable applications

      • Resiliency

    • Error handling in RxJava

      • Exploring the doOnError() operator

      • Reacting to an error

        • Recovering from an error

          • Absorb the error and switch over to the backup Observable which allows continuing the sequence using the onErrorResumeNext() operator

          • Absorb the error and emit a specified default item using the onErrorReturn() operator

          • Absorb the error and then try to restart the Observable that has failed using the onExceptionResumeNext() operator

          • Absorb the error and then try to restart the Observable which has failed using the retry() operator without delay

          • Absorb the error and then try to restart the Observable that has failed using the retryWhen() operator with delay

    • Exceptions specific to RxJava

      • CompositeException

      • MissingBackpressureException

      • OnErrorNotImplementedException

      • OnErrorFailedException

      • OnErrorThrowable

    • Error handler

      • Handling specific undeliverable exceptions

      • Exceptions introduced for tracking

      • Exception wrapping

    • Summary

  • Testing

    • Testing the need and role of a developer

    • The traditional way of testing an Observable

    • The modern approach for testing an Observable

      • The BaseTestConsumer class

      • The TestObserver class

      • The TestSubscriber class

      • Testing time-based Observable

        • The TestScheduler class

    • Testing the Subscriber

    • The test() operator

    • Testing notifications

      • Demonstration 1 - updating code for the just() operator

      • Demonstration 2 - updating the code for the never() operator

      • Demonstration 3 - updating the code for Flowable

      • Demonstration 4 - updating the code for the error() operator

      • Demonstration 5 - updating the code for the interval() operator

    • Mockito testing

    • Summary

  • Spring Reactive Web

    • An introduction to Spring Framework

      • Plumbing code

        • Scalability

        • Boilerplate code

        • Unit testing of the application

      • Features of the Spring Framework

        • POJO-based development

        • Loose coupling through Dependency Injection (DI)

        • Declarative programming

        • Boilerplate code reduction using aspects and templates

    • The Spring architecture

      • Core modules

        • Data access and integration modules

        • Web MVC and remoting modules

        • AOP modules

        • Instrumentation modules

        • Test modules

    • Project Reactor

      • Operators

    • Spring web Reactive Programming

    • Server-side support

      • Annotation-based support

      • The functional programming model

        • HandlerFunction

          • ServerRequest

          • ServerResponse

        • RouterFunction

    • Client side

      • Creating a WebClient instance

      • Using the WebClient instance to prepare a request

      • Reading the response

      • Deploying the application

        • Deploying the application from Eclipse IDE

        • Creating and deploying WAR file on server

      • Testing the application

        • Working with WebTestClient

    • Server-Sent Events (SSE)

    • Summary

  • Implementing Resiliency Patterns Using Hystrix

    • Hystrix- an introduction

      • How Hystrix works

      • Demonstrating HystrixCommand

    • Demonstrating HystrixObservableCommand

    • Handling fallback

      • Demonstrating HystrixCommand with a fallback

      • Demonstrating HystrixObservableCommand with fallback

    • Design patterns in resiliency

      • Bulkhead pattern

        • Partition the services

        • Partition the resources

        • Benefits

      • Circuit breaker

        • Proxy states

          • Closed state

          • Open state

          • Half-Open state

      • Retry pattern

        • Retry

        • Retrying after delay

        • Cancel

    • Queue-based load leveling pattern

    • Patterns used by Hystrix

      • Fail-fast

      • Fail-silent

      • Static fallback

      • Stubbed fallback

      • Cache via network fallback

      • Dual-mode fallback

      • Isolation

        • Using threads and thread pools for isolation

          • Reasons for using thread pools in Hystrix

          • Benefits of using thread and thread pools

          • Drawbacks of the thread pool

        • Semaphores

    • Request collapsing or request batching

      • The working

    • Request caching

      • Difference between request collapsing and request caching

    • Summary

  • Reactive Data Access

    • Spring Data

      • Modules provided by Spring Data

      • Features of Spring Data

    • Spring Data repositories

      • Using the repository

    • Spring Data and Reactive Programming

      • ReactiveCrudRepository

      • RxJava2CrudRepository

      • Spring Data Reactive and MongoDB

      • Features added to Spring Data MongoDB 2.0

        • Using MongoDB with Spring

          • RecativeMongoTemplate

          • Spring Data Repositories and MongoDB

      • ReactiveMongoRepository

    • Spring Data Reactive and Redis

      • Connecting to Redis

        • Jedis Connector

        • Lettuce connector

      • RedisTemplate

      • Spring Data Repositories and Redis

    • Kafka

      • Reactive API for Kafka

        • Reactor Kafka components for handling reactive pipelines

        • Sender

          • Creating the Sender

          • Creating messages

          • Sending messages

          • Closing the Sender

        • Receiver

          • Creating a Receiver instance

          • Reading the messages

    • Running the Kafka application

    • Summary

Nội dung

Reactive Programming With Java Develop concurrent and asynchronous applications with Java Tejaswini Mandar Jog BIRMINGHAM - MUMBAI Reactive Programming With Java Copyright © 2017 Packt Publishing All rights reserved No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews Every effort has been made in the preparation of this book to ensure the accuracy of the information presented However, the information contained in this book is sold without warranty, either express or implied Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals However, Packt Publishing cannot guarantee the accuracy of this information First published: September 2017 Production reference: 1190917 Published by Packt Publishing Ltd Livery Place 35 Livery Street Birmingham B3 2PB, UK ISBN 978-1-78712-423-3 www.packtpub.com Credits Author Copy Editor Tejaswini Mandar Jog Safis Editing Reviewer Project Coordinator Jay Lee Prajakta Naik Commissioning Editor Proofreader Aaron Lazar Safis Editing Acquisition Editor Indexer Karan Sadawana Francy Puthiry Content Development Editor Production Coordinator Lawrence Veigas Nilesh Mohite Technical Editor Tiksha Sarang About the Author Tejaswini Mandar Jog is a passionate and enthusiastic Java trainer She has more than nine years of experience in the IT training field, specializing in Java, J2EE, Spring, and relevant technologies She has worked with many renowned corporate companies on training and skill enhancement programs She is also involved in the development of projects using Java, Spring, and Hibernate Tejaswini has written two books In her first book, Learning Modular Java Programming, the reader explores the power of modular programming to build applications with Java and Spring The second book, Learning Spring 5.0, explores building an application using the Spring 5.0 framework with the latest modules such as WebFlux for dealing with reactive programming I am very lucky to get a chance to write another book on the newest concept in the market added to Java Nowadays, most the developers are talking about Java I got a chance not only to explore Java but also Reactive Programming It’s an exciting and challenging opportunity The challenge was to introduce the concepts in the manner so that the reader will be able to understand them without difficulty Thank you, Mandar, for being the first reader of the book and for giving sincere feedback Thank you so much for taking an active part in the writing process and helping me to improve This book would not have been completed without Lawrence Veigas, the editor, and Tiksha Sarang, the technical editor of the book The valuable input and comments from them helped a lot to improve the content The comments by the technical reviewer, Jay Lee, really made the difference Thank you, Jay Lee I want to take the opportunity to thank the Packt Pub team for all the effort at various stages of the book Without you guys, it wouldn’t have been possible How could I forget my lovely son, Ojas! Thank you, Ojas, for being so supportive and patient while I was busy with my work! Papa and Mumma, thank you for your support and encouragement, which motivates me to try giving my best Love you!! Finally, thank you all who helped by supporting me directly and indirectly to complete this book Thank you just for being with me as my biggest support About the Reviewer Jay Lee is currently working at Pivotal as senior platform architect His job is to help big enterprise Cloud-Native Journey with Spring, Spring Boot, Spring Cloud, and Cloud Foundry Before joining Pivotal, he spent 10 years at Oracle and worked with big enterprises for their large-scale Java distributed system and middleware Currently, Jay is authoring a microservices book (the name of the book is yet to be decided) using Spring Boot and Spring Cloud .. .Reactive Programming With Java Develop concurrent and asynchronous applications with Java Tejaswini Mandar Jog BIRMINGHAM - MUMBAI Reactive Programming With Java Copyright ©... currently working with Java or RxJava The book will also be helpful for all those who want to start working with reactive programming using Java In every chapter, we will start with a discussion... about functional programming in depth This book begins with explaining what reactive programming and the Reactive Manifesto is, and about the Reactive Streams specification It uses Java to introduce

Ngày đăng: 04/03/2019, 13:16

TỪ KHÓA LIÊN QUAN