Skip to content

Commit

Permalink
Merge pull request #77 from abes-esr/CDE-348-rapport-derreur-bad-limi…
Browse files Browse the repository at this point in the history
…ter-aux-erreurs-bloquantes

FEAT : CDE-348-rapport-derreur-bad-limiter-aux-erreurs-bloquantes :
  • Loading branch information
SamuelQuetin authored Feb 7, 2024
2 parents 2d48d2e + 5638737 commit f481f19
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 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
10 changes: 3 additions & 7 deletions src/main/resources/log4j2-all.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,11 @@
</Properties>
<Appenders>
<!-- KAFKA -->
<Kafka name="kafkaErrorLogAppender" topic="errorkbart2kafka" key="${ctx:package}">
<!-- Les levels d'erreurs pris en compte sont INFO, WARN et ERROR -->
<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}">
<JSONLayout />
<Property name="bootstrap.servers">${kafkaServer}</Property>
<LevelRangeFilter minLevel="INFO" maxLevel="INFO" onMatch="ACCEPT" onMismatch="DENY"/>
<LevelRangeFilter minLevel="INFO" maxLevel="ERROR" onMatch="ACCEPT" onMismatch="DENY"/>
</Kafka>
<!-- CONSOLE -->
<Console name="Console">
Expand Down

0 comments on commit f481f19

Please sign in to comment.