-
Notifications
You must be signed in to change notification settings - Fork 10
Whats New in Spring5 Reactive
#What's new in Spring 5
SpringOnePlatform 2017
sashin@pivotal.com @javapassion
Distributed Microservices architectures inheriently introduce latency, require redundancy and recovery, and the need to scale out, not up.
Reactive Manifesto:
- Responsive
- Resilient
- Elastic
- Message Driven
What is Reactive Programming:
- Non-Blocking, asyncyronous and event driven.
- Flow control (backpressure)
- Programming with async data streams
Event driven architectures have been around for a long time.
Backpressure - Don't over burden a component.
Require a Publisher and Subscriber. Subscriber subscribes to a Publisher and can then tell it how much data it can handle. You don't get data until you request(#)
as a subscriber.
onNext
- called when there is data
onError
- called on error
onComplete
- called when the data stream is complete (no more data will be available)
Implementations:
- Java 9
- Project Reactor
Any of the operators that end in With
will return a new Producer.
Flux is lazy and won't produce any thing in the stream until there is a subscriber.
How it's different than Java 8 Streams:
- Java 8 streams is a pull model. Reactive Streams are a push model. You don't have to wait until ALL the data is there.
Mongo/Redis/Cassandra have reactive repositories
The repositories are non-blocking.
-
Mono updateMovie(int id, Mono movie); vs
-
Mono updateMovie(int id, Movie movie); vs
-
Movie updateMovie(int id, Mono movie);
-
Provide a Mono as an argument if you don't immediately have the Movie available
-
Provide a Movie as an argument if there is no latency added by getting a movie object to update.
-
Return a Mono so the client doesn't have to wait. They will get a Movie when it is available.
You need to remember that the Publisher and Subscriber are running in different threads. With Reactive programming, you are writing multi-threaded code without any threading.
Why?
- Handle concurrency with a smaller number of threads
- Scale with less hardware
- Need to leverage functional programming apis to give declarative composition or async logic.
2 choices:
- Annotation based (same as before)
- Functional endpoints
Reactive and non-blocking doesn't necessiarly make your application faster.
flapmongo: https://github.com/flapdoodle-oss/de.flapdoodle.embed.mongo fongo: https://github.com/fakemongo/fongo
ACES Learn to Code
- Git, GitHub GH-Pages
- Ozone Platform Developer Setup
- HTML, JavaScript, CSS
- Tomcat Web Server Setup
- A Simple Node.js App
- Spark with Docker
- Best Practices for Software Development
Other Tutorials
Conferences
- 2018 - DevOps Days Baltimore
- 2018 DevOps Days Baltimore, Part 2
- DevOpsDays---Baltimore
- Cross-Domain-Technical-Forum
- 2017 Potential Conferences
- LAS December 5th 2016
- DI2E Plugfest 2016
- OSCON 2015
- RWX-2015
- SpringOne-2017
- OSCON-2018
- DinosaurJS 2018
Training
- Developing on AWS
- Agile Team Facilitation
- Amazon AWS Big Data Solutions Day
- Cloudera Developer Training for Spark and Hadoop May 2016