Created on 12-21-2015 04:10 AM - edited 09-16-2022 02:54 AM
Which methods/objects does Flink provide in order to enable users to read HTTP streams?
Created 12-22-2015 06:40 PM
I have prepared the Custom HTTPJSONStream reader and here is the attached code.
loganalytics.txt-> This is the main Class which fetches the data from the custom source. In our case its JSON via HTTP url.
httpjsonstream.txt -> This class implements the SourceFunction and provides a SourceContext of custom-type FlinkJSONObject
flinkjsonobject.txt -> This class uses java.net.* and javax.json.* to connect to provided URL and get the content in JSON Object format.
The logic can be applied on the JSONObject to get the desired results.
Please suggest if any changes can be made.
Created 12-21-2015 04:16 AM
The best information on this topic can be found on flink site. https://flink.apache.org/news/2015/02/09/streaming...
https://github.com/dataartisans/flink-streaming-de...
Not sure if it helps to customize for HTTP
Created 12-21-2015 05:59 AM
Thanks @Neeraj Sabharwal
For HTTP, I am in a state where I have to write a custom SourceFunction. Before I try it, I am exploring if there is a possibility to Handle HTTP Requests by using any of the existing StreamExecutionEnvironment functions/objects.
I am also trying to handle HTTP Stream for Flink using NiFi Connector as mentioned here
I hope either of these will help me in achieving desired results. 🙂
Created 12-21-2015 06:20 AM
Created 12-21-2015 03:33 PM
Sorry for the late reply. As I said in the other thread, I would recommend using a SourceFunction here. Feel free to post your code here as well, I can review it and give some hints for improving it.
Created 12-22-2015 06:40 PM
I have prepared the Custom HTTPJSONStream reader and here is the attached code.
loganalytics.txt-> This is the main Class which fetches the data from the custom source. In our case its JSON via HTTP url.
httpjsonstream.txt -> This class implements the SourceFunction and provides a SourceContext of custom-type FlinkJSONObject
flinkjsonobject.txt -> This class uses java.net.* and javax.json.* to connect to provided URL and get the content in JSON Object format.
The logic can be applied on the JSONObject to get the desired results.
Please suggest if any changes can be made.
Created 01-04-2016 08:32 AM
Thank you for posting the code here @Hemant Kumar. Sorry for the delay, I've now looked at and it looks good. If you want to optimize the code, I would try to move the code from the FlinkJSONObject constructor into the HTTPJSONStream class. It seems that the do/while loop is actually controlled from within the FlinkJSONObject.
Created 01-05-2016 06:40 AM
Thanks a lot @Robert Metzger