Git Product home page Git Product logo

flink-http-api-example's Introduction

flink-http-api-example

Steps to Run Application

  1. Have Java installed. We can do this with a tool called SDK Man.

    curl -s "https://get.sdkman.io" | bash
    source "$HOME/.sdkman/bin/sdkman-init.sh"
    
    sdk install java 11.0.23-zulu
    
  2. Run the Java program.

    git clone [email protected]:ericxiao251/flink-http-api-example.git
    cd flink-http-api-example/flink-http-api-example/
    
    ./gradlew run 
    

Main Pieces

  1. Java repo setup.

    Flink Dependencies: https://nightlies.apache.org/flink/flink-docs-release-1.16/docs/dev/configuration/overview/#gradle-build-script.

    Other Dependencies:

    • Http client.
    • JSON to Java Object (POJO) toolkit.
  2. A simple Flink application (Main.java).

    Example Main: https://nightlies.apache.org/flink/flink-docs-release-1.16/docs/dev/datastream/overview/#example-program. Example Flink Async I/O function: https://nightlies.apache.org/flink/flink-docs-master/docs/dev/datastream/operators/asyncio/#async-io-api.

  3. An class that implements the Async I/O abstract class in Flink.

    3 main abstract functions to implement:

    1. public void open(Configuration parameters). This is what I would call the "initializer" of the operator, where you can start the HTTP client.
    2. public void close(). This function is used to gracefully shutdown everything when your Flink application is turned off.
    3. public void asyncInvoke(String s, ResultFuture<String> resultFuture).
  4. (Optional) A Java "POJO" to represent the HTTP request response body, the Java way.

Main Things to Think About When Making HTTP Requests

  1. Async vs Synchronous

    Sometimes HTTP Requests can take a lot longer, we do not want to block and create a bottleneck in our system.

  2. Delivery Guarentees

  3. Authentication

  4. Retries

  5. Monitoring

    • Request duration
    • Request response code
    • Request volume/rate

    Some talks on how to do this in Flink: https://www.youtube.com/watch?v=XgumbKHE2Zw.

  6. Batching

flink-http-api-example's People

Contributors

ericxiao251 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.