Closed zcourts closed 7 years ago
I am having this for last 1 month. I keep on updating csdl and then do reconnect. I face this issue 1/5 times My code looks like try{ //trying to unsubscribe datasiftClient.liveStream().unsubscribe(currentStream); HttpRequestBuilder.restart(); //TODO need to check if we need to wait here till http client restarts. } catch(Exception e) { e.printStackTrace(); } }
datasiftClient.liveStream().subscribe(new StreamSubscription(stream) {
public void onDataSiftLogMessage(DataSiftMessage di) {
//di.isWarning() is also available
System.out.println((di.isError() ? "Error" : di.isInfo() ? "Info" : "Warning") + ":\n" + di);
}
public void onMessage(Interaction i) {
System.out.println("INTERACTION:\n" + i);
//deserializing incoming data to DataSiftData
Gson gson = new GsonBuilder().excludeFieldsWithModifiers(Modifier.TRANSIENT).create();
DataSiftData data = gson.fromJson(i.toString(), DataSiftData.class);
if(data.interaction.type.compareTo("facebook_page") == 0 && data.interaction.subtype.compareTo("page_like") == 0)
{
//ignoring the page like as we dont have any information of who liked the page.
Log.debug("ignoring page like");
}
else{
//updating interaction author.id with interaction.author.idstr
data.interaction.author.idStr = String.valueOf(data.interaction.author.id);
PostData postWithAlertObj = new PostData();
postWithAlertObj.setPostData(data);
postWithAlertObj.setProfileID(data.interaction.author.idStr);
postWithAlertObj.setInteractionID(data.interaction.id);
queue.offer(postWithAlertObj);
}
}
});
Why?
HttpRequestBuilder.restart();
Just doing
datasiftClient.liveStream().unsubscribe(currentStream);
is enough to unsubscribe from a stream. If you still receive interactions for a stream after unsubscribing then this is probably a bug (bare in mind that when you unsubscribe there may have been interactions already matched and need to be delivered).
@nishant-kumar12 I'll try to reproduce this issue again. This time using HttpRequestBuilder.restart();
to see if that helps reproduce the exception.
See https://github.com/datasift/datasift-java/issues/47#issuecomment-58490775