Skip to content

Commit b19ac10

Browse files
authored
Merge pull request #67 from abes-esr/CDE-425-opti-changer-les-cles-kafka
CDE 425 Opti Extraction du filename dans la clé
2 parents 439daeb + cb337b4 commit b19ac10

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/main/java/fr/abes/kafkatosudoc/kafka/KbartListener.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public KbartListener(UtilsMapper mapper, BaconService baconService, EmailService
7979
*/
8080
@KafkaListener(topics = {"${topic.name.source.kbart.toload}"}, groupId = "${topic.groupid.source.withppn}", containerFactory = "kafkaKbartListenerContainerFactory", concurrency = "${spring.kafka.concurrency.nbThread}")
8181
public void listenKbartToCreateFromKafka(ConsumerRecord<String, LigneKbartConnect> lignesKbart) throws IOException {
82-
String filename = lignesKbart.key();
82+
String filename = extractFilenameFromKey(lignesKbart.key());
8383
if (!this.workInProgressMap.containsKey(filename)) {
8484
this.workInProgressMap.put(filename, new WorkInProgress<>());
8585
lignesKbart.headers().forEach(header -> {
@@ -357,7 +357,7 @@ private void suppressionLien469(SudocService service, List<String> listError, in
357357
@KafkaListener(topics = {"${topic.name.source.kbart.exnihilo}"}, groupId = "${topic.groupid.source.exnihilo}", containerFactory = "kafkaKbartListenerContainerFactory")
358358
public void listenKbartFromKafkaExNihilo(ConsumerRecord<String, LigneKbartConnect> ligneKbart) {
359359
log.debug("Entrée dans création ex nihilo");
360-
String filename = ligneKbart.key();
360+
String filename = extractFilenameFromKey(ligneKbart.key());
361361

362362
// S'il s'agit d'un premier message d'un fichier kbart, on créé un WorkInProgress avec le nom du fichier et le nombre total de ligne
363363
if (!this.workInProgressMapExNihilo.containsKey(filename)) {
@@ -437,7 +437,7 @@ private void creerNoticeExNihilo(LigneKbartConnect ligneKbartConnect, String pro
437437
*/
438438
@KafkaListener(topics = {"${topic.name.source.kbart.imprime}"}, groupId = "${topic.groupid.source.imprime}", containerFactory = "kafkaKbartListenerContainerFactory")
439439
public void listenKbartFromKafkaImprime(ConsumerRecord<String, LigneKbartImprime> lignesKbart) {
440-
String filename = lignesKbart.key();
440+
String filename = extractFilenameFromKey(lignesKbart.key());
441441

442442
// S'il s'agit d'un premier message d'un fichier kbart, on créé un WorkInProgress avec le nom du fichier et le nombre total de ligne
443443
if (!this.workInProgressMapImprime.containsKey(filename)) {
@@ -527,4 +527,8 @@ private NoticeConcrete creerNoticeAPartirImprime(LigneKbartImprime ligneKbartImp
527527
throw e;
528528
}
529529
}
530+
531+
private String extractFilenameFromKey (String key) {
532+
return key.substring(0, key.lastIndexOf('_'));
533+
}
530534
}

0 commit comments

Comments
 (0)