Professional Resume Template for Software Developers
Social connections14: Super charge your API’s with Reactive streams
1. Berlin, October 16-17 2018
Super charge your API’s with Reactive streams
Frank van der Linden
Full stack Developer
elstar IT
2. Social Connections 14 Berlin, October 16-17 2018
Me
• Freelance Full stack Java developer
• Owner of elstar IT
• Curious of new technology
• IBM Champion
3. Social Connections 14 Berlin, October 16-17 2018
How to proceed
•Introduction of Reactive programming
•Spring Boot and Webflux
•Build your first reactive API
•Demo and coding
4. Social Connections 14 Berlin, October 16-17 2018
Introduction of Reactive
programming
5. Social Connections 14 Berlin, October 16-17 2018
Reactive programming is programming with asynchronous data streams.
7. Social Connections 14 Berlin, October 16-17 2018
Blocking API calls
• Limited amount of requests
• Could cause wait time
• Useful for request dependencies
9. Social Connections 14 Berlin, October 16-17 2018
Non-Blocking API calls
• (Almost) no limited requests
• Can process multiple requests
• Not knowing when response are returned
• Modern javascript frameworks rely on.
(Angular, React, VueJS)
11. Social Connections 14 Berlin, October 16-17 2018
Reactive manifesto
• Responsive: a reactive system needs to handle
requests in a reasonable time
• Resilient: a reactive system must stay responsive in
the face of failures
• Elastic: a reactive system must stay responsive
under various loads
• Message driven: components from reactive systems
interacts using asynchronous message passing
12. Social Connections 14 Berlin, October 16-17 2018
Publish/Subscribe principle
• Loose coupling
• Scalability
• Non-blocking
13. Social Connections 14 Berlin, October 16-17 2018
Reactive frameworks
• Node.js
• RxJava and RxJS
• Webflux
• Lightbend (Akka)
• Vertx
16. Social Connections 14 Berlin, October 16-17 2018
Spring boot
• Open Source, coordinated by Pivotal
• Java based applications
• Auto configure as much as possible
• Built in metrics and health checks
• Very good documentation
17. Social Connections 14 Berlin, October 16-17 2018
Spring boot - component scan
• @Service, @Controller, @Repository and
more @Components will be scanned
• @Autowired will glue everything together
18. Social Connections 14 Berlin, October 16-17 2018
Spring boot - runs everywhere
• Embedded Tomcat makes it just run
• Runs on Docker
• Runs on Cloud Foundry, like IBM and PCF
• Tomcat can excluded, then it runs on
Websphere, Tomcat or WildFly
• Even on Domino, http://hasselba.ch/blog/?
p=2589
20. Social Connections 14 Berlin, October 16-17 2018
Spring Webflux
• Part of the Spring Framework
• Available since Spring 5.0
• Uses Netty as webserver instead of Tomcat
• Uses the Reactor project under the hood
21. Social Connections 14 Berlin, October 16-17 2018
Spring Webflux - important objects
• Mono, returns 0 or 1 object
• Flux, returns 0 or N objects
• WebClient, reactive version of http client
26. Social Connections 14 Berlin, October 16-17 2018
Start your first reactive API
• Install Maven or Gradle
• Move to start.spring.io
• Fill in all the fields and select the dependencies
• Generate, download and open project in IDE
• Run ‘mvn clean install’ for all the dependencies
• Start coding
• Run application via ‘mvn spring-boot:run’
28. Social Connections 14 Berlin, October 16-17 2018
Project structure
• application.yaml =>
properties
• pom.xml =>
dependencies
29. Social Connections 14 Berlin, October 16-17 2018
Application properties
• port: on which the service is
available
• profiles: dev or prod
• can used in Java classes
• can also moved outside the
application
30. Social Connections 14 Berlin, October 16-17 2018
Repository
• Connect to MongoDb
• Auto config via property
• spring.data.mongodb.uri
31. Social Connections 14 Berlin, October 16-17 2018
Controller
• GET
• POST
• DELETE
• PATCH
32. Social Connections 14 Berlin, October 16-17 2018
Service
• Uses WebClient
• Connect to other
API’s
35. Social Connections 14 Berlin, October 16-17 2018
Router
• NEW RouterFunction
• Can replace the
Controller
• Uses a Handler class to
get the data (Common
scenario)
38. Social Connections 14 Berlin, October 16-17 2018
Demo application
• Spring boot
• Spring Webflux
• MongoDb
• Angular 6
https://bitbucket.org/flinden68/reactive-streams-starter/src/develop/
39. Social Connections 14 Berlin, October 16-17 2018
‘Live coding’: Add new functionality step by step
• Backend
• Model: Suggestion
• Repository, to connect to MongoDb
• Controller, the endpoints
• Test via Swagger (http://localhost:10000/swagger-ui.html)
• Frontend
• Model: Suggestion
• Service: GET, POST and DELETE
• Component: Add new methods
• HTML: Add suggestion tab
• Check in browser: ng serve (http://localhost:4200/index.html)
• Bonus
• Handler: Support the suggestions routes
• Router: Move all the routes to 1 class to handle all the route requests
• Test via Postman
40. Social Connections 14 Berlin, October 16-17 2018
Questions
Asynchronous coordinated lifecycles
Chai Stofkoper
41. Social Connections 14 Berlin, October 16-17 2018
Resources
• Spring Initializr
• http://start.spring.io/
• Spring Webflux
• https://docs.spring.io/spring/docs/current/spring-framework-reference/web-reactive.html
• Spring Boot
• https://projects.spring.io/spring-boot/
43. Social Connections 14 Berlin, October 16-17 2018
Reach out to me
• @flinden68
• http://www.elstarit.nl
• flinden68@elstarit.nl
• https://nl.linkedin.com/in/flinden68