Skip to content

Commit

Permalink
FEAT : CDE-348-rapport-derreur-bad-limiter-aux-erreurs-bloquantes :
Browse files Browse the repository at this point in the history
     - changement des log.error en log.warn pour les erreurs non bloquantes.
     - changement du topic de destination pour les log.info et log.warn
     - ajout d'un topic de destination pour les log.warn
  • Loading branch information
EryneKL committed Feb 6, 2024
1 parent d50b4b9 commit 0352431
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
6 changes: 2 additions & 4 deletions src/main/java/fr/abes/kbart2kafka/service/FileService.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
Expand Down Expand Up @@ -90,8 +89,7 @@ private void executeMultiThread(File fichier, String kbartHeader) throws IOExcep
assert result != null;
result.whenComplete((sr, ex) -> {
try {
// log.debug("Message envoyé : {}", mapper.writeValueAsString(result.get().getProducerRecord().value()));
mapper.writeValueAsString(result.get().getProducerRecord().value());
log.debug(mapper.writeValueAsString(result.get().getProducerRecord().value())); // vérification du résultat de la transaction et log
} catch (JsonProcessingException | InterruptedException | ExecutionException e) {
log.warn("Erreur dans le mapping du résultat de l'envoi dans le topic pour la ligne " + ligneKbartDto);
}
Expand All @@ -112,7 +110,7 @@ private void executeMultiThread(File fichier, String kbartHeader) throws IOExcep
}

private void sendErrorToKafka(String errorMessage, Exception exception, String filename) {
log.debug("Envoi erreur");
log.error(errorMessage + exception + " - " + filename);
kafkaTemplate.send(new ProducerRecord<>(topicErrors, new Random().nextInt(nbThread), filename, errorMessage + exception.getMessage()));
}

Expand Down
9 changes: 7 additions & 2 deletions src/main/resources/log4j2-all.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,21 @@
</Properties>
<Appenders>
<!-- KAFKA -->
<Kafka name="kafkaErrorLogAppender" topic="errorkbart2kafka" key="${ctx:package}">
<Kafka name="kafkaErrorLogAppender" topic="bacon.logs.toload" key="${ctx:package}">
<JSONLayout />
<Property name="bootstrap.servers">${kafkaServer}</Property>
<LevelRangeFilter minLevel="ERROR" maxLevel="ERROR" onMatch="ACCEPT" onMismatch="DENY"/>
</Kafka>
<Kafka name="kafkaInfoLogAppender" topic="infokbart2kafka" key="${ctx:package}">
<Kafka name="kafkaInfoLogAppender" topic="bacon.logs.toload" key="${ctx:package}">
<JSONLayout />
<Property name="bootstrap.servers">${kafkaServer}</Property>
<LevelRangeFilter minLevel="INFO" maxLevel="INFO" onMatch="ACCEPT" onMismatch="DENY"/>
</Kafka>
<Kafka name="kafkaInfoLogAppender" topic="bacon.logs.toload" key="${ctx:package}">
<JSONLayout />
<Property name="bootstrap.servers">${kafkaServer}</Property>
<LevelRangeFilter minLevel="WARN" maxLevel="WARN" onMatch="ACCEPT" onMismatch="DENY"/>
</Kafka>
<!-- CONSOLE -->
<Console name="Console">
<PatternLayout
Expand Down

0 comments on commit 0352431

Please sign in to comment.