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 full-size 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 full-size 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 full-size 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 full-size slide

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

    View full-size slide

  6. 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 full-size slide

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


    Mutiny Zero Adapters
    Vert.x -based


    stream publishers
    Mutiny Zero


    — minimal helper libraries to make publishers

    View full-size slide