Skip to content

Commit

Permalink
Reducing debug logs in AuditLogger
Browse files Browse the repository at this point in the history
- Wait for 5 seconds for new bulk of messages
- Wait until some messages are obtained
  • Loading branch information
Johana Supíková committed Mar 18, 2021
1 parent 4325585 commit f012410
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,19 +82,20 @@ public void run() {

int sleepTime = 1000;
//Waiting for new messages. If consumer failed in some internal case, waiting until it will be repaired (waiting time is increases by each attempt)
while(messages == null) {
while(messages == null || messages.isEmpty()) {
try {
//IMPORTANT STEP1: Get new bulk of messages
log.debug("Waiting for audit messages.");
messages = ((PerunBl)perun).getAuditMessagesManagerBl().pollConsumerMessages(perunSession, auditLoggerManager.getConsumerName(), lastProcessedIdNumber);
log.debug("Read {} new audit messages starting from {}", messages.size(), lastProcessedIdNumber);
if (messages.size() > 0) log.debug("Read {} new audit messages starting from {}", messages.size(), lastProcessedIdNumber);
} catch (InternalErrorException ex) {
log.error("Consumer failed due to {}. Sleeping for {} ms.", ex, sleepTime);
Thread.sleep(sleepTime);
sleepTime += sleepTime;
}

//If there are no messages, sleep for 1 sec and then try it again
if (messages == null) Thread.sleep(1000);
//If there are no messages, sleep for 5 sec and then try it again
if (messages == null || messages.isEmpty()) Thread.sleep(5000);
}
//If new messages exist, resolve them all
Iterator<AuditMessage> messagesIterator = messages.iterator();
Expand Down

0 comments on commit f012410

Please sign in to comment.