Reactive Application Development

Reactive Application Development

Paperback

$46.82 $49.99 Save 6% Current price is $46.82, Original price is $49.99. You Save 6%.
Choose Expedited Shipping at checkout for guaranteed delivery by Tuesday, October 22

Overview

Summary

Reactive Application Development is a hands-on guide that teaches you how to build reliable enterprise applications using reactive design patterns.

Purchase of the print book includes a free eBook in PDF, Kindle, and ePub formats from Manning Publications.

Foreword by Jonas Bonér, Creator of Akka

About the Technology

Mission-critical applications have to respond instantly to changes in load, recover gracefully from failure, and satisfy exacting requirements for performance, cost, and reliability. That's no small task! Reactive designs make it easier to meet these demands through modular, message-driven architecture, innovative tooling, and cloud-based infrastructure.

About the Book

Reactive Application Development teaches you how to build reliable enterprise applications using reactive design patterns. This hands-on guide begins by exposing you to the reactive mental model, along with a survey of core technologies like the Akka actors framework. Then, you'll build a proof-of-concept system in Scala, and learn to use patterns like CQRS and Event Sourcing. You'll master the principles of reactive design as you implement elasticity and resilience, integrate with traditional architectures, and learn powerful testing techniques.

What's Inside

  • Designing elastic domain models
  • Building fault-tolerant systems
  • Efficiently handling large data volumes
  • Examples can be built in Scala or Java

About the Reader

Written for Java or Scala programmers familiar with distributed application designs.

About the Author

Duncan DeVore, Sean Walsh, and Brian Hanafee are seasoned architects with experience building and deploying reactive systems in production.

Table of Contents

    PART 1 - FUNDAMENTALS
  1. What is a reactive application?
  2. Getting started with Akka
  3. Understanding Akka
  4. PART 2 - BUILDING A REACTIVE APPLICATION
  5. Mapping from domain to toolkit
  6. Domain-driven design
  7. Using remote actors
  8. Reactive streaming
  9. CQRS and Event Sourcing
  10. A reactive interface
  11. Production readiness

Product Details

ISBN-13: 9781617292460
Publisher: Manning Publications Company
Publication date: 08/15/2018
Pages: 288
Product dimensions: 7.30(w) x 8.70(h) x 0.70(d)

About the Author

Duncan DeVore is a Principal Systems Engineer at Lightbend, open source developer and frequent speaker. He has been an avid Scala developer since 2009, holds three patents for software design and led the release of one of the first large-scale Reactive applications in 2012.

Sean Walsh is CEO of reactibility.com and a seasoned architect with deep expertise in the Typesafe stack. He consults and evangelizes about reactive architectures.

Brian Hanafee is a Principal Systems Architect at a large financial institution, with experience building reliable and secure web-based applications and backing services for millions of customers.

Table of Contents

Foreword xi

Preface xiii

Acknowledgments xv

About this book xvi

About the authors xix

Part 1 Fundamentals 1

1 What is a reactive application? 3

1.1 Why do I need a reactive application? 5

Distributed computing 6

Cloud computing 6

1.2 Web shopping cart: complexity beneath the surface 7

Monolithic architecture: difficult to distribute 7

Reactive architecture: distributable by default 13

Understanding the reactive architecture 15

Monolithic shopping cart: creating an order 17

Event Sourcing: a banking example 20

Reactive shopping cart: creating an order with Event Sourcing 21

1.3 What are reactive applications reacting to? 25

1.4 What you will learn in this book 26

Asynchronous communication with loosely coupled design 26

Elastic 26

Resilient 27

Responsive 27

Testing 27

2 Getting started with Akka 29

2.1 Understanding messages and actors 30

Moving from functions to actors 30

Modeling the domain with actors and messages 32

Defining the messages 33

Defining the actors 34

2.2 Setting up the example project 36

2.3 Starting the actor system 38

Creating the driver 39

Running the driver 40

2.4 Distributing the actors over multiple systems 40

Distributing to two JVMs 40

Configuring for remote actors 41

Setting up the drivers 42

Running the distributed actors 44

2.5 Scaling with multiple actors 45

Traditional alternatives 45

Routing as an actor function 46

2.6 Creating a pool of actors 46

Adding the pool router 48

Running the pooled actor system 49

2.7 Scaling with multiple-actor systems 50

Adding the group router 50

Running the multiple actor systems 52

2.8 Applying reactive principles 52

3 Understanding Akka 54

3.1 What is Akka? 55

3.2 Akka today 57

Becoming responsive 57

Retaining data reliably 58

Increasing resiliency and elasticity 58

Supporting Big Data with Spark 59

3.3 Akka terminology 59

Concurrency and parallelism 59

Asynchronous and synchronous 60

Contention 63

Share nothing 65

3.4 The actor model 66

State 67

Actor reference 67

Asynchronous message passing 68

The mailbox 69

Behavior and the receive loop 70

Supervision 76

3.5 The actor system 77

Hierarchical structure 77

Supervision 79

Actor paths 79

Actor lifecycle 81

Microkernel container 82

Part 2 Building a Reactive Application 85

4 Mapping from domain to toolkit 87

4.1 Designing from a domain model 88

A better solution 88

Moving from analogy to application 89

Creating the catalog 90

4.2 Becoming message-driven 91

4.3 Controlling actor state with messages 93

Sending messages to yourself 94

Changing behavior with state 95

Managing more complex interactions 97

Keeping it simple 101

Running the application 103

Reviewing progress 104

4.4 Increasing elasticity 105

Akka routing 105

Dispatchers 108

Running the application with routers 110

4.5 Resilience 110

Faulty Librarian actor 111

Running the faulty application 113

Librarian supervision 113

Running the application with resilient supervision 114

5 Domain-driven design 116

5.1 What is domain-driven design? 117

The Big Ball of Mud 118

Bounded context 122

Ubiquitous language 124

Entities, aggregates, and value objects 124

Services, repositories, and factories 127

Anticorruption layers 130

Layered architecture 131

Sagas 131

Shared kernel 132

5.2 An actor-based domain 132

A simple Akka aircraft domain 132

The actor 134

The process manager 135

6 Using remote actors 138

6.1 Refactoring to a distributed system 139

Splitting into multiple actor systems 139

Structuring with sbt 141

6.2 Configuring the applications 141

Creating the first driver application 142

Introducing application.conf 143

Using HOCON 144

Configuring the driver application 145

6.3 Remoting with Akka 146

Constructing remote references 146

Resolving the references 146

Replacing clients with peers 148

Creating another driver 151

6.4 Running the distributed example 153

Starting the customer application 154

Starting the RareBooks application 155

Creating some customers 155

Reviewing the results 155

6.5 Reliability in distributed systems 156

Reliability as a design parameter 157

Akka guarantees 159

7 Reactive streaming 164

7.1 Buffering too many messages 165

7.2 Defending with backpressure 166

Stopping and waiting 166

Signaling for more than one message 169

Controlling the stream 170

7.3 Streaming with Akka 171

Adding streams to a project 172

Creating a stream source from a file 173

Transforming the stream 174

Converting the stream to actor messages 175

Putting it together 176

7.4 Introducing Reactive Streams 177

Creating a Reactive Stream 178

Consuming the Reactive-Stream 179

Building applications with streaming 180

8 CQRS and Event Sourcing 181

8.1 Driving factors toward CQRS/ES 182

ACID transactions 182

Traditional RDBMS lack of sharding 183

Crud 183

8.2 CQRS origins: command, queries, and two distinct paths 184

8.3 The C in CQRS 187

What is a command? 188

Rejection 188

Atomicity 188

Jack of all trades, master of none 189

Lack of behavior 190

Order example: the order commands 190

Nonbreaking command validation 192

Conflict resolution 194

8.4 The Q in CQRS 195

Impedance mismatch 195

What is a query? 197

Dynamic queries not needed 199

Relational versus NoSQL 199

8.5 Event Sourcing 200

What is an event? 200

It's all about behavior 202

Life beyond distributed transactions 202

The order example 202

Consistency revisited 206

Retry patterns 207

Command sourcing versus Event Sourcing 207

9 A reactive interface 209

9.1 What is a reactive interface? 210

The API layer 210

The headless API 210

9.2 Expressive RESTful interfaces 211

JSON vs XML 212

Expressive RESTful interface URLs 212

Location 213

9.3 Choosing your reactive API library 214

Play 214

Opinionation 215

Application structure 215

A simple route 217

Nonblocking service interfaces 218

9.4 Akka HTTP: a simple CQRS-esque service 220

9.5 Lagom: the order example 224

9.6 Play vs Akka HTTP vs Lagom 225

10 Production readiness 227

10.1 Testing a reactive application 228

Identifying test patterns 228

Testing concurrent behavior 229

10.2 Securing the application 231

Taking threats in STRIDE 231

Barbarians at the gate 232

Adding HTTPS 233

10.3 Logging actors 235

Stackable logs 235

Configuring the log system 236

10.4 Tracing messages 238

Collecting trace data with the Dapper pattern 239

Reducing dependencies with Open Tracing 241

Integrating Open Tracing with Akka 242

Finding pathways with the Spider pattern 249

10.5 Monitoring a reactive application 250

Monitoring core metrics with Lightbend Monitoring 250

Creating a custom metric with Kamon 251

10.6 Handling failure 251

Deciding what to restart 252

Routing considerations 252

Recovering, to a point 253

10.7 Deploying to a cloud 254

Isolating the factors 254

Dockerizing actors 256

Other packaging options 257

Index 259

Customer Reviews

Most Helpful Customer Reviews

See All Customer Reviews