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

Event-driven and serverless with Spring Cloud Function, Spring Cloud Stream, and Spring Native

Event-driven and serverless with Spring Cloud Function, Spring Cloud Stream, and Spring Native

Thomas Vitale

May 20, 2021
Tweet

More Decks by Thomas Vitale

Other Decks in Technology

Transcript

  1. Thomas Vitale
    Spring User Group Italy
    May 20th, 2021
    Event-driven and serverless
    With Spring Cloud Function, Spring Cloud Stream,
    and Spring Native
    @vitalethomas

    View Slide

  2. Thomas Vitale
    • Senior Software Engineer at
    Systematic, Denmark.

    • Spring, Cloud Native, DevOps,
    Kubernetes, Application Security.

    • Author of “Cloud Native Spring in
    Action - With Spring Boot and
    Kubernetes” (Manning).
    About Me

    View Slide

  3. Functional Programming Paradigm
    Java 8 Functional Interfaces
    • Supplier

    • Function

    • Consumer
    thomasvitale.com @vitalethomas

    View Slide

  4. Spring Cloud Function
    thomasvitale.com @vitalethomas

    View Slide

  5. Spring Cloud Function
    Promote the implementation of business logic via functions
    • Transparent type conversion of inputs and outputs

    • Function composition (imperative, reactive, hybrid)

    • Function arity (multiple inputs/outputs)

    • POJO functions

    • Deployment of functions as JARs

    • Reactive support
    thomasvitale.com @vitalethomas

    View Slide

  6. Spring Cloud Function
    Function composition
    Order
    Accepted
    Order
    Dispatched
    Dispatcher Service
    Function Composition (Overview)
    pack() label()
    Input data Output data
    Data processing
    thomasvitale.com @vitalethomas

    View Slide

  7. Spring Cloud Function
    Function composition
    pack()
    OrderAccepted
    Message
    Long label()
    Flux
    FluxDispatched
    Message>
    Function Composition (Details)
    thomasvitale.com @vitalethomas

    View Slide

  8. Spring Cloud Function
    Serverless and event-driven
    • Functions exposed as HTTP endpoints and/or messaging channels

    • Integration with serverless platform

    • AWS Lambda

    • Azure Functions

    • Google Cloud Functions

    • Integration with event brokers

    • Spring Cloud Stream (RabbitMQ, Kafka) @vitalethomas

    View Slide

  9. Spring Native
    thomasvitale.com @vitalethomas

    View Slide

  10. Spring Native
    Native executables with GraalVM
    • Bene
    fi
    ts

    • Instant startup

    • Instant peak performance

    • Reduced memory consumption

    • Drawbacks

    • Slow and heavy build process

    • Fewer runtime optimizations

    • Con
    fi
    g for re
    fl
    ection and proxies
    @vitalethomas

    View Slide

  11. Spring Cloud Stream
    thomasvitale.com @vitalethomas

    View Slide

  12. Spring Cloud Stream
    Event-driven microservices
    • Integration with event brokers (RabbitMQ, Kafka, Kafka Streams)

    • Bindings between functions and external messaging systems

    • Publish/Subscribe

    • Consumer Groups

    • Partitions
    thomasvitale.com @vitalethomas

    View Slide

  13. Spring Cloud Stream
    Application Model
    Destination Binder
    Destination
    Binding
    Kafka RabbitMQ
    Function
    Spring Boot Application
    Destination
    Binding
    Spring Cloud Stream - Application Model
    thomasvitale.com @vitalethomas

    View Slide

  14. Spring Cloud Stream
    RabbitMQ
    Consumer
    Producer Exchange
    Queue
    Queue Consumer
    Message Broker
    routes
    messages
    to
    routes
    messages
    to
    sends
    messages
    to
    receives
    messages
    from
    receives
    messages
    from
    AMQP message routing
    thomasvitale.com @vitalethomas

    View Slide

  15. Thomas Vitale
    Spring User Group Italy
    May 20th, 2021
    Event-driven and serverless
    With Spring Cloud Function, Spring Cloud Stream,
    and Spring Native
    @vitalethomas

    View Slide