Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Reactive Microservices with Spring Boot and JHipster - Spring I/O 2022

Reactive Microservices with Spring Boot and JHipster - Spring I/O 2022

Microservice architectures are all the rage in JavaLand. They allow teams to develop services independently and deploy autonomously.

Why microservices?

IF
  you are developing a large/complex application
AND
  you need to deliver it rapidly, frequently, and reliably over a long period of time
THEN
  the Microservice Architecture is often a good choice.

Reactive architectures are becoming increasingly popular for organizations that need to do more, with less hardware. Reactive programming allows you to build systems that are resilient to high load.

In this session, I'll show you how to use JHipster to create a reactive microservices architecture with Spring Boot, Spring Cloud, Keycloak, and run it all in Docker. You will leave with the know-how to create your own resilient apps!

Related blog post: https://developer.okta.com/blog/2021/01/20/reactive-java-microservices
YouTube demo: https://youtu.be/clkEUHWT9-M
GitHub repo: https://github.com/oktadev/java-microservices-examples/tree/main/reactive-jhipster

72a2082c6a4dd79ad68befb3db911616?s=128

Matt Raible
PRO

May 26, 2022
Tweet

More Decks by Matt Raible

Other Decks in Programming

Transcript

  1. Reactive Java Microservices with Spring Boot and JHipster May 26,

    2022 Matt Raible | @mraible Photo by Ken Cheung 
 https://unsplash.com/photos/VbLTNceBTFE
  2. None
  3. What is JHipster?

  4. How to Use JHipster Install JHipster using npm: npm install

    -g generator-jhipster Create a directory and cd into it: take app Run it! jhipster
  5. Monolith, Gateway, or Microservices? Spring MVC or Spring WebFlux? Authentication

    Type? Database Type? Build Tool? Web Framework? JHipster Options
  6. https://start.jhipster.tech

  7. Thriving OSS Project Started by Julien Dubois on October 21,

    2013 App Generator, Platform, Learning Tool …
  8. @mraible Hi, I’m Matt Raible Father, Husband, Skier, Mountain Biker,

    Whitewater Rafter Bus Lover Web Developer and Java Champion Okta Developer Advocate Blogger on raibledesigns.com and developer.okta.com/blog @mraible
  9. None
  10. None
  11. None
  12. developer.okta.com

  13. Spring History of Spring October 2002 - Rod Johnson writes

    J2EE Design & Development 2004 - Spring 1.0 2006 - Spring 2.0 with better XML 2009 - JavaConfig 2014 - Spring Boot 1.0 2015 - Spring Cloud 1.0 🍃
  14. Microservices Visionaries

  15. “Any organization that designs a system (defined broadly) will produce

    a design whose structure is a copy of the organization's communication structure.” Conway’s Law Melvin Conway 1967
  16. None
  17. “Do one thing and do it well.”

  18. None
  19. None
  20. Spring WebFlux!

  21. Spring MVC Code @PostMapping("/points") public ResponseEntity<Points> createPoints(@Valid @RequestBody Points points)

    throws URISyntaxException { log.debug("REST request to save Points : {}", points); if (points.getId() != null) { throw new BadRequestAlertException("A new points cannot already have an ID", ENTITY_NAME, "idexists"); } Points result = pointsRepository.save(points); pointsSearchRepository.save(result); return ResponseEntity .created(new URI("/api/points/" + result.getId())) .headers(HeaderUtil.createEntityCreationAlert( applicationName, true, ENTITY_NAME, result.getId().toString())) .body(result); }
  22. Spring WebFlux Code @PostMapping("/points") public Mono<ResponseEntity<Points>> createPoints(@Valid @RequestBody Points points)

    throws URISyntaxException { log.debug("REST request to save Points : {}", points); if (points.getId() != null) { throw new BadRequestAlertException("A new points cannot already have an ID", ENTITY_NAME, "idexists"); } return pointsRepository .save(points) .flatMap(pointsSearchRepository::save) .map( result -> { try { return ResponseEntity .created(new URI("/api/points/" + result.getId())) .headers(HeaderUtil.createEntityCreationAlert( applicationName, true, ENTITY_NAME, result.getId().toString())) .body(result); } catch (URISyntaxException e) { throw new RuntimeException(e); } } ); }
  23. Spring Cloud Gateway

  24. yelp.com/callback Back to redirect URI with authorization code Exchange code

    for access token and ID token accounts.google.com Email ********** Go to authorization server Redirect URI: yelp.com/cb Scope: openid profile Authorization Server yelp.com Connect with Google Resource owner Client accounts.google.com 
 Allow Yelp to access your public profile and contacts? No Yes Request consent from resource owner Hello Matt! accounts.google Get user info 
 with access token /userinfo OAuth 2.0 and OIDC
  25. None
  26. Demo Create microservices with JDL Run apps and e2e tests

    Switch identity providers Run everything with Docker https://github.com/oktadev/java- microservices-examples 🤓
  27. Reactive Microservices with Spring Cloud Gateway https://developer.okta.com/blog/2019/08/28/reactive-microservices-spring-cloud-gateway

  28. What You Learned

  29. https://developer.okta.com/blog/2021/01/20/reactive-java-microservices

  30. https://developer.okta.com/blog/2021/06/01/kubernetes-spring-boot-jhipster

  31. npm install -g generator-jhipster-kotlin

  32. https://wiki.openjdk.java.net/display/loom/Main

  33. What’s Next for JHipster? Micro Frontends Spring Native GraphQL *

    These are my personal interests.
  34. JHipster is Knowledge

  35. The JHipster Mini-Book 
 Written with Asciidoctor Free download from

    InfoQ: infoq.com/minibooks/jhipster-mini-book Quick and to the point, 164 pages Developed a real world app: www.21-points.com Buy for $20 or download for FREE
  36. The Angular Mini-Book 
 Written with Asciidoctor Free download from

    InfoQ: infoq.com/minibooks/angular-mini-book Angular 13 and Spring Boot 2.6 Angular Material, Bootstrap, Kotlin Spring Security and best practices Deploy separate apps and single artifact
  37. Learn More stackoverflow.com Spring Boot spring.io/guides JHipster www.jhipster.tech Okta APIs

    developer.okta.com
  38. developer.okta.com/blog @oktadev

  39. Action: Try JHipster! 🚀 npm i -g generator-jhipster@7

  40. git clone https://github.com/oktadeveloper/okta-spring-webflux-react- example.git https://github.com/oktadev/java-microservices-examples Use the Source, Luke!

  41. developer.okta.com

  42. Thanks! Keep in Touch raibledesigns.com @mraible Presentations speakerdeck.com/mraible Code github.com/oktadev

    developer.okta.com