Skip to content

Commit

Permalink
Using constants
Browse files Browse the repository at this point in the history
  • Loading branch information
louis-tw committed Feb 16, 2024
1 parent cff4ef3 commit 55a56dd
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -77,7 +77,8 @@

@Slf4j
public class KafkaTasksExecutionTriggerer implements ITasksExecutionTriggerer, GracefulShutdownStrategy, InitializingBean {

private static final int MAX_KAFKA_PRODUCER_INSTANTIATION_ATTEMPTS = 5;
private static final int KAFKA_PRODUCER_INSTANTIATION_FAILURE_WAIT_TIME_MS = 500;
@Autowired
private ITasksProcessingService tasksProcessingService;
@Autowired
@@ -503,11 +504,11 @@ private KafkaProducer<String, String> createKafkaProducer() {
attemptsCount++;
kafkaProducer = new KafkaProducer<>(configs);
} catch (KafkaException e) {
if (attemptsCount >= 5) {
if (attemptsCount >= MAX_KAFKA_PRODUCER_INSTANTIATION_ATTEMPTS) {
throw e;
}
log.error("Creating Kafka producer failed. Attempt #{}", attemptsCount, e);
WaitUtils.sleepQuietly(Duration.ofMillis(500));
WaitUtils.sleepQuietly(Duration.ofMillis(KAFKA_PRODUCER_INSTANTIATION_FAILURE_WAIT_TIME_MS));
}
}
coreMetricsTemplate.registerKafkaProducer(kafkaProducer);

0 comments on commit 55a56dd

Please sign in to comment.