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

Quarkus Insights 2023-03-06

Quarkus Insights 2023-03-06

Julien Ponge

March 06, 2023
Tweet

More Decks by Julien Ponge

Other Decks in Programming

Transcript

  1. java.util.stream.*
    java.util.concurrent.Flow.*
    2 kinds of “stream” APIs
    Efficient in-memory


    data stream processing
    Backpressured async I/O


    data stream processing

    View Slide

  2. “Reactive Streams is an initiative to provide a
    standard for asynchronous stream
    processing with non-blocking back pressure.”


    — https:/
    /www.reactive-streams.org/
    Mutiny!
    Photo by Arno Senoner on Unsplash

    View Slide

  3. org.reactivestreams.*


    (Java 6 legacy)
    java.util.concurrent.Flow.*


    (since JDK 9)
    Back-pressured, asynchronous, non-blocking


    (see Reactive Streams TCK)
    < your own library / client / driver / … >
    APIs
    Protocol
    User-facing


    APIs

    View Slide

  4. return flux


    .filter(n
    ->
    n % 2
    ==
    0)


    .map(n
    ->
    "[" + n + "]")


    .flatMap(Database
    ::
    record)


    .retry(5);
    return multi


    .select().where(n
    ->
    n % 2
    ==
    0)


    .onItem().transform(n
    ->
    "[" + n + "]")


    .onItem().transformToUniAndMerge(Database
    ::
    record)


    .onFailure()


    .retry()


    .withBackOff(Duration.ofSeconds(1))


    .atMost(5);


    RxJava / Reactor Mutiny
    Functional dialect,
    fl
    at 100+ methods list
    Event-based dialect,
    group-based api

    View Slide

  5. Ok, 4 interfaces. Must be easy, right?
    Publisher Subscriber
    Processor Subscription

    View Slide

  6. View Slide

  7. View Slide

  8. View Slide

  9. View Slide

  10. View Slide

  11. Migrate to Flow
    Use adapters
    Strategies: from legacy to Flow
    Support both APIs
    New APIs. Same TCK.
    Best for 3rd-party libraries


    that haven’t migrated yet.


    Virtually no-cost.
    Transition for user code:


    RESTEasy Reactive,


    Reactive Messaging, …

    View Slide

  12. Mutiny Zero
    (44 Kilobytes JAR)
    RS <-> Flow


    Mutiny Zero Adapters
    Vert.x -based


    stream publishers
    Mutiny Zero


    — minimal helper libraries to make publishers

    View Slide