How to get Rest Stream in java /scala code in streaming way
How to get Rest Stream in java /scala code in streaming way
I have streaming rest url which is streaming response in json format .
I want to send that response on Kafka topic .
for non stream response I can get send the repononce to kafka .
but when i am using stream rest than it failed .
it gets hanged and in last it gets time out.'
String streamURI = "http://stream.rest/call";
String nonStreamURI ="http://non-stream.rest/call";
URL url = new URL(nonStreamURI);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("GET");
conn.setRequestProperty("Accept", "application/json");
if (conn.getResponseCode() != 200)
throw new RuntimeException("Failed : HTTP error code : "
+ conn.getResponseCode());
BufferedReader br = new BufferedReader(new InputStreamReader(
(conn.getInputStream())));
String output;
while ((output = br.readLine()) != null)
// Publish message to kafka
sorry i have framed question wrongly . the problem is while consuming the stream rest response .
– anuj1807
2 days ago
Are you able to print out the results instead of
// Publish message to kafka
? Or is the Kafka code the actual problem?– cricket_007
2 days ago
// Publish message to kafka
nope I am just trying to print out kafka code i can add it but at this point of time i am not even able to print it in case of REST STREAM , in case of normal rest i can print it
– anuj1807
2 days ago
I'm not sure I understand the problem here. Are you having issues with Kafka code, or reading a stream from a URL? Please show your KafkaProducer logic if that's the actual problem
– cricket_007
2 days ago
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Kafka clients are open source... What difficulties are you having implementing one?
– cricket_007
Aug 18 at 15:47