Skip to content

Commit

Permalink
Fix: suppression filename dans Header
Browse files Browse the repository at this point in the history
Correction compteur nombre de lignes
  • Loading branch information
pierre-maraval committed Jan 23, 2024
1 parent ea848f0 commit 400ddd4
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/main/java/fr/abes/kbart2kafka/service/FileService.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ private void executeMultiThread(File fichier, String kbartHeader) throws IOExcep
Integer nbLignesFichier = fileContent.size() - 1;
log.debug("Début d'envoi de "+ nbLignesFichier + " lignes du fichier");
for (String ligneKbart : fileContent) {
lineCounter++;
if (!ligneKbart.contains(kbartHeader)) {
lineCounter++;
// Crée un nouvel objet dto, set les différentes parties et envoi au service topicProducer
String[] tsvElementsOnOneLine = ligneKbart.split("\t");
LigneKbartDto ligneKbartDto = constructDto(tsvElementsOnOneLine);
Expand All @@ -83,7 +83,6 @@ private void executeMultiThread(File fichier, String kbartHeader) throws IOExcep
try {
ThreadContext.put("package", fichier.getName());
List<org.apache.kafka.common.header.Header> headers = new ArrayList<>();
headers.add(new RecordHeader("FileName", fichier.getName().getBytes(StandardCharsets.UTF_8)));
headers.add(new RecordHeader("nbCurrentLines", String.valueOf(finalLineCounter).getBytes()));
headers.add(new RecordHeader("nbLinesTotal", String.valueOf(nbLignesFichier).getBytes()));
ProducerRecord<String, String> record = new ProducerRecord<>(topicKbart, new Random().nextInt(nbThread), fichier.getName(), mapper.writeValueAsString(ligneKbartDto), headers);
Expand Down

0 comments on commit 400ddd4

Please sign in to comment.