reactive-jhipster/demo.adoc GitHub repo: <a href=https://speakerdeck.com/mraible/"https://github.com/oktadev/auth0-java-microservices-examples/tree/main/reactive-jhipster">@oktadev/auth0-java-microservices-examples"> reactive-jhipster/demo.adoc GitHub repo: <a href=https://speakerdeck.com/mraible/"https://github.com/oktadev/auth0-java-microservices-examples/tree/main/reactive-jhipster">@oktadev/auth0-java-microservices-examples">
Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Reactive Java Microservices with Spring Boot and JHipster - Kansas City JUG 2023

Reactive Java Microservices with Spring Boot and JHipster - Kansas City JUG 2023

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!

Demo script: reactive-jhipster/demo.adoc
GitHub repo: @oktadev/auth0-java-microservices-examples

Matt Raible
PRO

June 08, 2023
Tweet

More Decks by Matt Raible

Other Decks in Programming

Transcript

  1. Reactive Java Microservices


    with Spring Boot and JHipster
    June 8, 2023
    Matt Raible | @mraible
    Photo by Tianyi Ma

    https://unsplash.com/photos/o7f4K13f2eE

    View Slide

  2. View Slide

  3. What is JHipster?

    View Slide

  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

    View Slide

  5. Monolith, Gateway, or Microservices?


    Spring MVC or Spring WebFlux?


    Authentication Type?


    Database Type?


    Build Tool?


    Web Framework?
    JHipster Options

    View Slide

  6. https://start.jhipster.tech

    View Slide

  7. Thriving OSS Project
    Started by Julien Dubois on October 21, 2013
    App Generator, Platform, Learning Tool …

    View Slide

  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

    View Slide

  9. View Slide

  10. View Slide

  11. View Slide

  12. developer.okta.com

    View Slide

  13. developer.auth0.com

    View Slide

  14. 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
    🍃

    View Slide

  15. Microservices Visionaries

    View Slide

  16. “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

    View Slide

  17. View Slide

  18. “Do one thing and do it well.”

    View Slide

  19. View Slide

  20. View Slide

  21. Spring WebFlux!

    View Slide

  22. Spring MVC Code
    @PostMapping("/points")


    public ResponseEntity 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);


    }

    View Slide

  23. Spring WebFlux Code
    @PostMapping("/points")


    public Mono> 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);


    }


    }


    );


    }

    View Slide

  24. Spring Cloud Gateway

    View Slide

  25. 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: yelp.com/callback


    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

    View Slide

  26. View Slide

  27. Demo
    Create microservices with JDL


    Run apps and e2e tests


    Switch identity providers


    Run everything with Docker


    https://github.com/oktadev/auth0-
    java-microservices-examples
    🤓

    View Slide

  28. https://auth0.com/blog/micro-frontends-for-java-microservices

    View Slide

  29. https://github.com/jhipster/jhipster-lite

    View Slide

  30. What You Learned

    View Slide

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

    View Slide

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

    View Slide

  33. npm install -g generator-jhipster-kotlin

    View Slide

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

    View Slide

  35. https://spring.io/blog/2023/02/27/web-applications-and-project-loom

    View Slide

  36. JHipster is Knowledge

    View Slide

  37. The JHipster Mini-Book

    Written with Asciidoctor


    Free download from InfoQ:


    infoq.com/minibooks/jhipster-mini-book


    Quick and to the point, 161 pages


    Developed a real-world app:


    www.21-points.com


    Buy for $20 or download for FREE

    View Slide

  38. The Angular Mini-Book

    Written with Asciidoctor


    Free download from InfoQ:


    infoq.com/minibooks/angular-mini-book


    Angular 15 and Spring Boot 3.0


    Angular Material, Bootstrap, Kotlin


    Spring Security and best practices


    Deploy separate apps and single artifact

    View Slide

  39. Learn More
    stackoverflow.com
    Spring Boot


    spring.io/guides
    JHipster


    www.jhipster.tech
    Auth0


    developer.auth0.com

    View Slide

  40. developer.okta.com/blog/tags/java


    @oktadev

    View Slide

  41. developer.auth0.com


    @auth0

    View Slide

  42. Join us as an Auth0 Ambassador!
    auth0.com/ambassador-program

    View Slide

  43. https://a0.to/nl-signup/java


    https://developer.auth0.com/newsletter

    View Slide

  44. Action: Try JHipster! 🚀
    npm i -g generator-jhipster

    View Slide

  45. git clone https://github.com/oktadeveloper/okta-spring-web
    fl
    ux-react-example.git
    https://github.com/oktadev/auth0-java-microservices-examples
    Use the Source, Luke!

    View Slide

  46. developer.okta.com

    View Slide

  47. Thanks!


    Keep in Touch


    raibledesigns.com


    @mraible


    Presentations


    speakerdeck.com/mraible


    Code


    github.com/oktadev
    developer.auth0.com

    View Slide