Skip to content

Commit

Permalink
Fix executor pas reset
Browse files Browse the repository at this point in the history
  • Loading branch information
SamuelQuetin committed Oct 30, 2024
1 parent 03994e3 commit 5909bd6
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/main/java/fr/abes/kbart2kafka/service/FileService.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@
import fr.abes.kbart2kafka.exception.IllegalFileFormatException;
import fr.abes.kbart2kafka.utils.PUBLICATION_TYPE;
import fr.abes.kbart2kafka.utils.Utils;
import jakarta.annotation.PostConstruct;
import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.clients.producer.ProducerRecord;
import org.apache.logging.log4j.ThreadContext;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Service;
import org.yaml.snakeyaml.util.EnumUtils;

import java.io.BufferedReader;
import java.io.File;
Expand Down Expand Up @@ -49,7 +47,7 @@ public FileService(KafkaTemplate<String, String> kafkaTemplate, ObjectMapper map
this.lastThreadUsed = new AtomicInteger(0);
}

@PostConstruct
// @PostConstruct
void initExecutor() {
executor = Executors.newFixedThreadPool(nbThread);
}
Expand All @@ -60,6 +58,7 @@ public void loadFile(File fichier) throws IllegalFileFormatException, IOExceptio
}

private void executeMultiThread(File fichier) throws IllegalFileFormatException {
initExecutor();
try (BufferedReader buff = new BufferedReader(new FileReader(fichier))) {
List<String> fileContent = buff.lines().toList();
List<String> kbartsToSend = new ArrayList<>();
Expand Down

0 comments on commit 5909bd6

Please sign in to comment.