Skip to content

Commit

Permalink
remove duplicate message from logging
Browse files Browse the repository at this point in the history
  • Loading branch information
SaitTalhaNisanci committed Sep 24, 2018
1 parent 01267ef commit f40deaa
Showing 1 changed file with 15 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,6 @@ public void onResponse(ReadResultSet<ReliableTopicMessage> result) {
if (cancelled) {
return;
}

try {
listener.storeSequence(sequence);
process(message);
Expand All @@ -247,14 +246,13 @@ public void onResponse(ReadResultSet<ReliableTopicMessage> result) {
return;
}
}

sequence++;
}

next();
}

private void process(ReliableTopicMessage message) throws Throwable {
private void process(ReliableTopicMessage message) {
// proxy.localTopicStats.incrementReceives();
listener.onMessage(toMessage(message));
}
Expand All @@ -276,6 +274,8 @@ public void onFailure(Throwable t) {
}

t = peel(t);
String baseMessage = "Terminating MessageListener:" + listener + " on topic: " + name + ". "
+ "Reason: ";
if (t instanceof StaleSequenceException) {
// StaleSequenceException.getHeadSeq() is not available on the client-side, see #7317
long remoteHeadSeq = ringbuffer.headSequence();
Expand All @@ -289,27 +289,23 @@ public void onFailure(Throwable t) {
next();
return;
}
logger.warning("Terminating MessageListener:" + listener + " on topic: " + name + ". "
+ "Reason: The listener was too slow or the retention period of the message has been violated. "
logger.warning(baseMessage + "The listener was too slow or the retention period of the "
+ "message has been violated. "
+ "head: " + remoteHeadSeq + " sequence:" + sequence);
} else if (t instanceof HazelcastInstanceNotActiveException) {
if (logger.isFinestEnabled()) {
logger.finest("Terminating MessageListener " + listener + " on topic: " + name + ". "
+ " Reason: HazelcastInstance is shutting down");
logger.finest(baseMessage + "HazelcastInstance is shutting down");
}
} else if (t instanceof DistributedObjectDestroyedException) {
if (logger.isFinestEnabled()) {
logger.finest("Terminating MessageListener " + listener + " on topic: " + name + ". "
+ "Reason: Topic is destroyed");
logger.finest(baseMessage + "Topic is destroyed");
}
} else if (t instanceof HazelcastClientNotActiveException || t instanceof RejectedExecutionException) {
if (logger.isFinestEnabled()) {
logger.finest("Terminating MessageListener " + listener + " on topic: " + name + ". "
+ "Reason: HazelcastClient is shutting down");
logger.finest(baseMessage + "HazelcastClient is shutting down");
}
} else {
logger.warning("Terminating MessageListener " + listener + " on topic: " + name + ". "
+ "Reason: Unhandled exception, message: " + t.getMessage(), t);
logger.warning(baseMessage + "Unhandled exception, message: " + t.getMessage(), t);
}
cancel();
}
Expand All @@ -323,12 +319,13 @@ private boolean terminate(Throwable failure) {
if (cancelled) {
return true;
}

String baseMessage = "Terminating MessageListener:" + listener + " on topic: " + name + ". "
+ "Reason: ";
try {
boolean terminate = listener.isTerminal(failure);
if (terminate) {
logger.warning("Terminating MessageListener " + listener + " on topic: " + name + ". "
+ "Reason: Unhandled exception, message: " + failure.getMessage(), failure);
logger.warning(baseMessage
+ "Unhandled exception, message: " + failure.getMessage(), failure);
} else {
if (logger.isFinestEnabled()) {
logger.finest("MessageListener " + listener + " on topic: " + name + " ran into an exception:"
Expand All @@ -337,8 +334,8 @@ private boolean terminate(Throwable failure) {
}
return terminate;
} catch (Throwable t) {
logger.warning("Terminating messageListener:" + listener + " on topic: " + name + ". "
+ "Reason: Unhandled exception while calling ReliableMessageListener.isTerminal() method", t);
logger.warning(baseMessage
+ "Unhandled exception while calling ReliableMessageListener.isTerminal() method", t);
return true;
}
}
Expand Down

0 comments on commit f40deaa

Please sign in to comment.