Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEAT : CDE-348-rapport-derreur-bad-limiter-aux-erreurs-bloquantes : #77

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 -->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Je pense qu'il y a moyen de faire une seule et unique balise kafka
en jouant sur le minLevel et maxLevel

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Effectivement, c'est fait 👍

<Console name="Console">
<PatternLayout
Expand Down
Loading