Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Reactive Programming
for Java developers
Part 1
Long Running
Shift To
Concurrency
10 years ago
Today
Design async API with
Java Futures
...
...
...
...
...
...
...
...
...
...
...
Async return values
as a stream?
Return type Use case Notifications
void Success onComplete()
void Failure onError(Throwable)
User Match onNext(User), onCo...
Java 8 Stream
Java 8 Stream
Reactive Streams
public interface Subscriber<T> {
void onSubscribe(Subscription sub);
void onNext(T item);
void onError(Throwable ex);
void...
Project Reactor
Mono [0..1] sequence
onSubscribe
request(unbounded)
onNext(User: Jason)
onNext(User: Jay)
...
onComplete()
onSubscribe
request(2)
onNext(User: Jason)
onNext(User: Jay)
request(2)
onNext(User: Joe)
onNext(User: John)
...
Reactive
Web Applications
Part 2
public UserRepositoryImpl implements UserRepository {
public Mono<User> findUser(Long id) {
|
}
}
Flux<T> Flux<DataBuffer>
More HttpServer variants at
spring-web/src/test/java
Imperative to Reactive Web Applications
Imperative to Reactive Web Applications
Imperative to Reactive Web Applications
Imperative to Reactive Web Applications
Imperative to Reactive Web Applications
Imperative to Reactive Web Applications
Imperative to Reactive Web Applications
Imperative to Reactive Web Applications
Imperative to Reactive Web Applications
Imperative to Reactive Web Applications
Imperative to Reactive Web Applications
Imperative to Reactive Web Applications
Imperative to Reactive Web Applications
Imperative to Reactive Web Applications
Imperative to Reactive Web Applications
Imperative to Reactive Web Applications
Imperative to Reactive Web Applications
Imperative to Reactive Web Applications
Imperative to Reactive Web Applications
Imperative to Reactive Web Applications
Imperative to Reactive Web Applications
Imperative to Reactive Web Applications
Imperative to Reactive Web Applications
Imperative to Reactive Web Applications
Imperative to Reactive Web Applications
Imperative to Reactive Web Applications
Imperative to Reactive Web Applications
Imperative to Reactive Web Applications
Imperative to Reactive Web Applications
Imperative to Reactive Web Applications
Imperative to Reactive Web Applications
Imperative to Reactive Web Applications
Imperative to Reactive Web Applications
Imperative to Reactive Web Applications
Imperative to Reactive Web Applications
Imperative to Reactive Web Applications
Imperative to Reactive Web Applications
Imperative to Reactive Web Applications
Upcoming SlideShare
Loading in …5
×

Imperative to Reactive Web Applications

3,035 views

Published on

SpringOne Platform 2016
Speaker: Rossen Stoyanchev; Spring Framework Developer, Pivotal

The reactive programming model involves a fundamental shift from imperative to non-blocking logic and understanding what that means on the most basic level is an essential and required first step. In this talk we'll start by introducing reactive programming and discuss how it impacts application design. Then we'll take a look at the building blocks from a Java developer's perspective. Finally we'll complete the picture by checking out the upcoming Spring 5 support for reactive web applications.

Published in: Technology

Imperative to Reactive Web Applications

  1. 1. Reactive Programming for Java developers Part 1
  2. 2. Long Running Shift To Concurrency
  3. 3. 10 years ago Today
  4. 4. Design async API with Java Futures
  5. 5. ... ...
  6. 6. ...
  7. 7. ... ...
  8. 8. ... ...
  9. 9. ... ...
  10. 10. ... ...
  11. 11. Async return values as a stream?
  12. 12. Return type Use case Notifications void Success onComplete() void Failure onError(Throwable) User Match onNext(User), onComplete() User No match onComplete() User Failure onError(Throwable) List<User> Two matches onNext(User), onNext(User), onComplete() List<User> No match onComplete() List<User> Failure onError(Throwable)
  13. 13. Java 8 Stream
  14. 14. Java 8 Stream
  15. 15. Reactive Streams
  16. 16. public interface Subscriber<T> { void onSubscribe(Subscription sub); void onNext(T item); void onError(Throwable ex); void onComplete(); } public interface Subscription { void request(long n); void cancel(); } public interface Publisher<T> { void subscribe(Subscriber<? super T> subscriber); } Reactive Streams
  17. 17. Project Reactor
  18. 18. Mono [0..1] sequence
  19. 19. onSubscribe request(unbounded) onNext(User: Jason) onNext(User: Jay) ... onComplete()
  20. 20. onSubscribe request(2) onNext(User: Jason) onNext(User: Jay) request(2) onNext(User: Joe) onNext(User: John) ...
  21. 21. Reactive Web Applications Part 2
  22. 22. public UserRepositoryImpl implements UserRepository { public Mono<User> findUser(Long id) { | } }
  23. 23. Flux<T> Flux<DataBuffer>
  24. 24. More HttpServer variants at spring-web/src/test/java

×