setUrl( new URL(queryForAll));
begin = beginTimestamp;
end = endTimestamp;
}
public void run() {
SoProducer producer = new SoProducer();
HttpURLConnection request = null;
try
{
request = (HttpURLConnection) url
.openConnection();
request.setConnectTimeout(connect_timeout);
request.setReadTimeout(read_timeout);
request.connect();
if (request.getResponseCode() == 200)
{
StringBuilder sb = new StringBuilder();
String line;
try (InputStream is = request.getInputStream();
GZIPInputStream gzip = new GZIPInputStream(is);
InputStreamReader isr = new InputStreamReader(gzip);
BufferedReader br = new BufferedReader(isr))
{
while ((line = br.readLine()) != null) {
sb.append(line);
}
String answer = sb.toString();
System.out.println(Long.toString(Thread.currentThread().getId()));
answer = postProcessing(answer);
producer.send("car", answer);
//System.out.println(answer);
}
} else {
LOGGER.warn("Response cde is not 200. RC: " +
Integer.toString(request.getResponseCode()));
}
}
catch (IOException e)
{
LOGGER.error("error while fetching data",e);
} finally {
if (request != null) {
request.disconnect();
}
producer.close();
}
}