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
in Spring 5
Arjen Poutsma
Pivotal
About Arjen
• Twenty years of experience in Enterprise
Software Development
• Joined SpringSource in 2005
• Development le...
Agenda
• Reactive Systems
• Reactive Streams
• RxJava
• Reactor
• Reactive Programming in Spring 5
Reactive Systems
Reactive Manifesto
Responsive
Message Driven
ResilientElastic
Reactive Manifesto
• Responsive
• Rapid
• Consistent
• Resilient
• Replication
• Isolation
• Elastic
• Scaling
• No bottle...
Reactive Streams
Reactive Streams Spec
• Focus on Interoperability
• No operators
• Wide support
• Akka,Vert.x, RxJava, Ratpack
• JDK 9 Flo...
Publisher Subscriber
Publisher Subscribersubscribe
Publisher Subscriber
Publisher Subscriber
Publisher Subscriber
onSubscribe
Subscription
Publisher Subscriber
Subscription
Subscription
Publisher Subscriber
Subscription
Publisher Subscriber
request
2
Subscription
Publisher Subscriber
2
Subscription
Publisher Subscriber
2
Subscription
Publisher Subscriber
onNext
1
Subscription
Publisher Subscriber
1
Subscription
Publisher Subscriber
onNext
0
Subscription
Publisher Subscriber
0
Subscription
Publisher Subscriber
request
5
Subscription
Publisher Subscriber
5
Subscription
Publisher Subscriber
5
Subscription
Publisher Subscriber
onNext
4
Subscription
Publisher Subscriber
4
Subscription
Publisher Subscriber
onNext
3
Subscription
Publisher Subscriber
3
Subscription
Publisher Subscriber
onNext
2
Subscription
Publisher Subscriber
2
Subscription
Publisher Subscriber
onComplete
2
Publisher Subscribersubscribe
onSubscribe
Subscription
request
onNext
onComplete
onError
Hot & Cold
Cold Hot
Passive Active
Publish when
subscribed
Publish regardless
Queue Mouse Movement
Operators
• map, flatMap, take, subscribe, …
• No Operators in Reactive Streams
• Left to implementations
Reactor
Project Reactor
• Stream extends Publisher
• Wrap Publisher
Reactor
Streams.just('a' 'b' 'c')
.take(2)
.map(Character::toUpperCase)
.consume(System.out::println);
RxJava
RxJava
• Based On Reactive Extensions
• Ported to many languages
• Rx.NET, RxJava, RxJS, ...
• Native support for Reactive...
RxJava
Observable.just('a', 'b', 'c')
.take(2)
.map(Character::toUpperCase)
.subscribe(System.out::println)
RxNetty
• RxJava on top of Netty
• Client/server for TCP and HTTP
• Backpressure support
Spring 5
Spring Reactive
• Experimental work for Spring 5
• Non-blocking runtimes:
• Netty, Jetty,Tomcat, (Undertow)
• RxJava, Reac...
public interface ServerHttpRequest {
HttpMethod getMethod();
URI getURI();
InputStream getBody();
}
public interface Serve...
public interface ReactiveServerHttpRequest {
HttpMethod getMethod();
URI getURI();
Publisher<ByteBuffer> getBody();
}
publ...
Reactive Wep App
Web Service Data
Wanted: Reactiveness
• JDBC
• MySQL
• Postgres
• NoSQL
• MongoDB
• HTTP Client
• OkHttp
• Spring 5
• …
Reactor
@RequestMapping("/capitalize")
@ResponseBody
public Stream<Person> capitalize(
@RequestBody Stream<Person> persons...
RxJava
@RequestMapping("/capitalize")
@ResponseBody
public Observable<Person> capitalize(
@RequestBody Observable<Person> ...
More Spring!
Spring Meetup
http://www.meetup.com/Dutch-Spring-
Meetup/
Spring Track GOTO Amsterdam 2016
http://gotoams.com
Q & A
https://github.com/spring-projects/spring-reactive
You’ve finished this document.
Download and read it offline.
Upcoming SlideShare
Reactive Spring Framework 5
Next
Upcoming SlideShare
Reactive Spring Framework 5
Next
Download to read offline and view in fullscreen.

Share

Reactive Programming in Spring 5

Download to read offline

Presented at Dutch Spring Meetup on 19-11-2015.

Related Books

Free with a 30 day trial from Scribd

See all

Related Audiobooks

Free with a 30 day trial from Scribd

See all

Reactive Programming in Spring 5

  1. 1. Reactive Programming in Spring 5 Arjen Poutsma Pivotal
  2. 2. About Arjen • Twenty years of experience in Enterprise Software Development • Joined SpringSource in 2005 • Development lead of Spring Web Services, Spring REST support, Spring Scala • Working on Spring 5
  3. 3. Agenda • Reactive Systems • Reactive Streams • RxJava • Reactor • Reactive Programming in Spring 5
  4. 4. Reactive Systems
  5. 5. Reactive Manifesto Responsive Message Driven ResilientElastic
  6. 6. Reactive Manifesto • Responsive • Rapid • Consistent • Resilient • Replication • Isolation • Elastic • Scaling • No bottlenecks • Message Driven • Async • Back-pressure
  7. 7. Reactive Streams
  8. 8. Reactive Streams Spec • Focus on Interoperability • No operators • Wide support • Akka,Vert.x, RxJava, Ratpack • JDK 9 Flow in java.util.concurrent
  9. 9. Publisher Subscriber
  10. 10. Publisher Subscribersubscribe
  11. 11. Publisher Subscriber
  12. 12. Publisher Subscriber
  13. 13. Publisher Subscriber onSubscribe Subscription
  14. 14. Publisher Subscriber Subscription
  15. 15. Subscription Publisher Subscriber
  16. 16. Subscription Publisher Subscriber request 2
  17. 17. Subscription Publisher Subscriber 2
  18. 18. Subscription Publisher Subscriber 2
  19. 19. Subscription Publisher Subscriber onNext 1
  20. 20. Subscription Publisher Subscriber 1
  21. 21. Subscription Publisher Subscriber onNext 0
  22. 22. Subscription Publisher Subscriber 0
  23. 23. Subscription Publisher Subscriber request 5
  24. 24. Subscription Publisher Subscriber 5
  25. 25. Subscription Publisher Subscriber 5
  26. 26. Subscription Publisher Subscriber onNext 4
  27. 27. Subscription Publisher Subscriber 4
  28. 28. Subscription Publisher Subscriber onNext 3
  29. 29. Subscription Publisher Subscriber 3
  30. 30. Subscription Publisher Subscriber onNext 2
  31. 31. Subscription Publisher Subscriber 2
  32. 32. Subscription Publisher Subscriber onComplete 2
  33. 33. Publisher Subscribersubscribe onSubscribe Subscription request onNext onComplete onError
  34. 34. Hot & Cold Cold Hot Passive Active Publish when subscribed Publish regardless Queue Mouse Movement
  35. 35. Operators • map, flatMap, take, subscribe, … • No Operators in Reactive Streams • Left to implementations
  36. 36. Reactor
  37. 37. Project Reactor • Stream extends Publisher • Wrap Publisher
  38. 38. Reactor Streams.just('a' 'b' 'c') .take(2) .map(Character::toUpperCase) .consume(System.out::println);
  39. 39. RxJava
  40. 40. RxJava • Based On Reactive Extensions • Ported to many languages • Rx.NET, RxJava, RxJS, ... • Native support for Reactive Streams coming in 2.x
  41. 41. RxJava Observable.just('a', 'b', 'c') .take(2) .map(Character::toUpperCase) .subscribe(System.out::println)
  42. 42. RxNetty • RxJava on top of Netty • Client/server for TCP and HTTP • Backpressure support
  43. 43. Spring 5
  44. 44. Spring Reactive • Experimental work for Spring 5 • Non-blocking runtimes: • Netty, Jetty,Tomcat, (Undertow) • RxJava, Reactor https://github.com/spring-projects/spring-reactive
  45. 45. public interface ServerHttpRequest { HttpMethod getMethod(); URI getURI(); InputStream getBody(); } public interface ServerHttpResponse { void setStatusCode(HttpStatus status); OutputStream getBody(); } HttpMessage
  46. 46. public interface ReactiveServerHttpRequest { HttpMethod getMethod(); URI getURI(); Publisher<ByteBuffer> getBody(); } public interface ServerHttpResponse { void setStatusCode(HttpStatus status); Publisher<void> setBody(Publisher<ByteBuffer> body); } Reactive HttpMessage
  47. 47. Reactive Wep App Web Service Data
  48. 48. Wanted: Reactiveness • JDBC • MySQL • Postgres • NoSQL • MongoDB • HTTP Client • OkHttp • Spring 5 • …
  49. 49. Reactor @RequestMapping("/capitalize") @ResponseBody public Stream<Person> capitalize( @RequestBody Stream<Person> persons) { return persons.map(person -> { person.setName(person.getName().toUpperCase()); return person; }); }
  50. 50. RxJava @RequestMapping("/capitalize") @ResponseBody public Observable<Person> capitalize( @RequestBody Observable<Person> persons) { return persons.map(person -> { person.setName(person.getName().toUpperCase()); return person; }); }
  51. 51. More Spring! Spring Meetup http://www.meetup.com/Dutch-Spring- Meetup/ Spring Track GOTO Amsterdam 2016 http://gotoams.com
  52. 52. Q & A https://github.com/spring-projects/spring-reactive
  • samanzone

    Nov. 14, 2019
  • siyufeifei

    Apr. 10, 2017
  • changhwanhan1

    Nov. 17, 2016
  • piotrwittchen

    Sep. 12, 2016
  • srinirengasamy7

    Jul. 31, 2016
  • factoradix

    Jun. 9, 2016
  • LuisMoraMedina

    Jun. 7, 2016
  • sandarkin

    May. 5, 2016
  • kirubakaran7

    Jan. 31, 2016
  • SreekumarGopalakrishnan1

    Jan. 21, 2016
  • AaronJung

    Dec. 11, 2015
  • objectx

    Dec. 1, 2015
  • YanAshenkampf

    Nov. 22, 2015
  • uhashimi

    Nov. 22, 2015
  • mythii

    Nov. 22, 2015
  • dongwq

    Nov. 22, 2015
  • ryojia

    Nov. 22, 2015

Presented at Dutch Spring Meetup on 19-11-2015.

Views

Total views

5,463

On Slideshare

0

From embeds

0

Number of embeds

68

Actions

Downloads

143

Shares

0

Comments

0

Likes

17

×