diff --git a/src/main/java/fr/abes/bestppn/kafka/TopicConsumer.java b/src/main/java/fr/abes/bestppn/kafka/TopicConsumer.java index b76af4e..ccfa108 100644 --- a/src/main/java/fr/abes/bestppn/kafka/TopicConsumer.java +++ b/src/main/java/fr/abes/bestppn/kafka/TopicConsumer.java @@ -69,7 +69,7 @@ public void kbartFromkafkaListener(ConsumerRecord ligneKbart) { LigneKbartDto ligneKbartDto = mapper.readValue(ligneKbart.value(), LigneKbartDto.class); String providerName = Utils.extractProvider(filename); try { - log.info("Partition;" + ligneKbart.partition() + ";offset;" + ligneKbart.offset() + ";fichier;" + filename + ";" + Thread.currentThread().getName()); + log.debug("Partition;" + ligneKbart.partition() + ";offset;" + ligneKbart.offset() + ";fichier;" + filename + ";" + Thread.currentThread().getName()); int origineNbCurrentLine = ligneKbartDto.getNbCurrentLines(); ThreadContext.put("package", (filename + ";" + origineNbCurrentLine)); //Ajoute le nom de fichier dans le contexte du thread pour log4j service.processConsumerRecord(ligneKbartDto, providerName, workInProgress.get(filename).isForced(), workInProgress.get(filename).isBypassed(), filename); @@ -127,18 +127,6 @@ private void handleFichier(String filename) { } } - @KafkaListener(topics = {"${topic.name.source.kbart.errors}"}, groupId = "${topic.groupid.source.errors}", containerFactory = "kafkaKbartListenerContainerFactory") - public void errorsListener(ConsumerRecord error) { - log.error(error.value()); - String filename = extractFilenameFromKey(error.key()); - if (workInProgress.containsKey(filename)) { - emailService.sendProductionErrorEmail(filename, error.value()); - logFileService.createExecutionReport(filename, workInProgress.get(filename).getExecutionReport(), workInProgress.get(filename).isForced()); - workInProgress.get(filename).setIsOnError(true); - handleFichier(filename); - } - } - private String extractFilenameFromKey (String key) { return key.substring(0, key.lastIndexOf('_')); } diff --git a/src/main/java/fr/abes/bestppn/service/EmailService.java b/src/main/java/fr/abes/bestppn/service/EmailService.java index f212781..b1cc027 100644 --- a/src/main/java/fr/abes/bestppn/service/EmailService.java +++ b/src/main/java/fr/abes/bestppn/service/EmailService.java @@ -53,7 +53,7 @@ public void sendMailWithAttachment(String packageName, PackageKbartDto mailAttac createAttachment(mailAttachment, csvPath); // Création du mail - String requestJson = mailToJSON(this.recipient, "[CONVERGENCE]["+env.toUpperCase()+"] Rapport de traitement BestPPN " + packageName + ".csv", ""); + String requestJson = mailToJSON(this.recipient, "[KBART2BACON : Rapport BestPPN]" + getTag() + " " + packageName, ""); // Récupération du fichier File file = csvPath.toFile(); @@ -175,9 +175,17 @@ protected String mailToJSON(String to, String subject, String text) { public void sendProductionErrorEmail(String packageName, String message) { // Création du mail - String requestJson = mailToJSON(this.recipient, "[CONVERGENCE]["+env.toUpperCase()+"] Rapport de traitement BestPPN " + packageName, message); + String requestJson = mailToJSON(this.recipient, "[KBART2BACON : erreurs]" + getTag() + " " + packageName, message); // Envoi du message par mail sendMail(requestJson); } + + private String getTag(){ + if(env.equalsIgnoreCase("PROD")){ + return ""; + } else { + return "[" + env.toUpperCase() + "]"; + } + } } diff --git a/src/main/java/fr/abes/bestppn/service/WsService.java b/src/main/java/fr/abes/bestppn/service/WsService.java index 7e26bf5..83ad8e2 100644 --- a/src/main/java/fr/abes/bestppn/service/WsService.java +++ b/src/main/java/fr/abes/bestppn/service/WsService.java @@ -159,14 +159,14 @@ public ResultWsSudocDto callDoi2Ppn(String doi, @Nullable String provider) throw params.put("doi", doi.toUpperCase()); params.put("provider", provider); ResultWsSudocDto result = new ResultWsSudocDto(); - String resultCall = getCall(urlDoi2Ppn, params); - if (!resultCall.isEmpty()) { - result = mapper.readValue(resultCall, ResultWsSudocDto.class); - result.setUrl(urlDoi2Ppn + "?provider=" + provider + "&doi=" + doi); - } - else { - log.info("doi : " + doi + " / provider " + provider + " : aucun ppn ne correspond à la recherche"); - } + String resultCall = getCall(urlDoi2Ppn, params); + result.setUrl(urlDoi2Ppn + "?provider=" + provider + "&doi=" + doi); + if (!resultCall.isEmpty()) { + result = mapper.readValue(resultCall, ResultWsSudocDto.class); + } + else { + log.info("doi : " + doi + " / provider " + provider + " : aucun ppn ne correspond à la recherche"); + } return result; } diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 681305a..73daedc 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -26,8 +26,6 @@ topic.name.target.kbart=bacon.kbart.withppn.toload topic.name.target.noticeimprime=bacon.kbart.sudoc.imprime.tocreate topic.name.target.ppnFromKbart=bacon.kbart.sudoc.tocreate.exnihilo topic.name.source.kbart=bacon.kbart.toload -topic.name.source.kbart.errors=bacon.kbart.toload.errors -topic.name.source.nbLines=bacon.kbart.toload.nbLines topic.name.target.kbart.bypass.toload=bacon.kbart.bypass.toload spring.jpa.open-in-view=false