Skip to content

Commit

Permalink
Modif config
Browse files Browse the repository at this point in the history
  • Loading branch information
SamuelQuetin committed Oct 15, 2024
1 parent e70e390 commit 843ebad
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 14 deletions.
11 changes: 6 additions & 5 deletions src/main/java/fr/abes/logskbart/configuration/KafkaConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,25 @@
import java.sql.Timestamp;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

@Configuration
@EnableKafka
public class KafkaConfig {
@Value("${spring.kafka.consumer.bootstrap-servers}")
@Value("${abes.kafka.bootstrap-servers}")
private String bootstrapAddress;

@Value("${topic.groupid.source}")
private String groupId;


@Bean
public ConsumerFactory<String, String> consumerLogsFactory() {
Map<String, Object> props = new HashMap<>();
props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapAddress);
props.put(ConsumerConfig.GROUP_ID_CONFIG, groupId);
props.put(ConsumerConfig.GROUP_INSTANCE_ID_CONFIG,("SchedulerCoordinator"+ UUID.randomUUID()));
props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class);
props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class);
props.put(ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG, true);
props.put(ConsumerConfig.MAX_POLL_RECORDS_CONFIG, 10);
props.put(ConsumerConfig.MAX_POLL_INTERVAL_MS_CONFIG, 60000);
return new DefaultKafkaConsumerFactory<>(props);
}

Expand Down
4 changes: 3 additions & 1 deletion src/main/java/fr/abes/logskbart/service/EmailService.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public void sendEmail(String packageName, String message) {

// Envoi du message par mail
sendMail(requestJson);

log.info("L'email a été correctement envoyé à " + recipient);
}

public void sendMailWithAttachment(String packageName, Path mailAttachmentPath) {
Expand All @@ -57,7 +59,7 @@ public void sendMailWithAttachment(String packageName, Path mailAttachmentPath)
// Suppression du fichier temporaire
Files.deleteIfExists(mailAttachmentPath);

log.info("L'email a été correctement envoyé à " + recipient);
log.info("L'email avec PJ a été correctement envoyé à " + recipient);

} catch (IOException e) {
throw new RuntimeException(e);
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/application-dev.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Consumer properties
spring.kafka.consumer.bootstrap-servers=
abes.kafka.bootstrap-servers=
abes.kafka.concurrency.nbThread=

# Properties defined from .env on server #ignore resolution error
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/application-prod.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Consumer properties
spring.kafka.consumer.bootstrap-servers=
abes.kafka.bootstrap-servers=
abes.kafka.concurrency.nbThread=

# Base Postgres
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/application-test.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Consumer properties
spring.kafka.consumer.bootstrap-servers=
abes.kafka.bootstrap-servers=
abes.kafka.concurrency.nbThread=

# Properties defined from .env on server #ignore resolution error
Expand Down
5 changes: 0 additions & 5 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ server.port=8082
# Configuration des logs
log4j2.logdir=logs

# Common Kafka Properties
spring.kafka.consumer.key-serializer=org.apache.kafka.common.serialization.StringSerializer
spring.kafka.consumer.value-serializer=org.apache.kafka.common.serialization.StringSerializer
spring.kafka.consumer.max-poll-records=10000

# Topic Kafka
topic.name.source.error=bacon.logs.toload
# Pour la partie consumer : insertion dans kafka de la ligne kbart avec bestppn
Expand Down

0 comments on commit 843ebad

Please sign in to comment.