Skip to content

Commit

Permalink
Initial code for email service with few refractor
Browse files Browse the repository at this point in the history
  • Loading branch information
jayasudhasundaram committed Dec 5, 2024
1 parent 28d42ae commit 94dec41
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 42 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package gov.cdc.datacompareesender.configuration;

import com.fasterxml.jackson.databind.deser.std.StringDeserializer;
import org.apache.kafka.common.serialization.StringDeserializer;
import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.clients.consumer.ConsumerConfig;
import org.springframework.beans.factory.annotation.Value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider;
import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.s3.S3Client;
import software.amazon.awssdk.services.s3.model.GetObjectRequest;
import software.amazon.awssdk.services.s3.presigner.S3Presigner;
import software.amazon.awssdk.services.s3.presigner.model.GetObjectPresignRequest;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package gov.cdc.datacompareesender.service;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.Gson;
import gov.cdc.datacompareesender.model.EmailEventModel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.kafka.annotation.KafkaListener;
Expand All @@ -10,17 +10,17 @@
@Slf4j
public class KafkaEmailConsumerService {
private final EmailService emailService;
private final ObjectMapper objectMapper;
private final Gson objectMapper;

public KafkaEmailConsumerService(EmailService emailService, ObjectMapper objectMapper) {
public KafkaEmailConsumerService(EmailService emailService, Gson objectMapper) {
this.emailService = emailService;
this.objectMapper = objectMapper;
}

@KafkaListener(topics = "${kafka.topic.data-compare-topic}")
public void handleMessage(String message) {
try {
EmailEventModel emailEvent = objectMapper.readValue(message, EmailEventModel.class);
EmailEventModel emailEvent = objectMapper.fromJson(message, EmailEventModel.class);
log.info("Processing email request for file: {}", emailEvent.getFileName());
emailService.sendComparisonEmail(emailEvent);
log.info("Email sent successfully for file: {}", emailEvent.getFileName());
Expand Down
23 changes: 16 additions & 7 deletions DataCompareESender/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
spring:
kafka:
bootstrap-servers: ${KAFKA_BOOTSTRAP_SERVERS}
bootstrap-servers: ${KAFKA_BOOTSTRAP_SERVER}
group-id: data-compare-email-group

kafka:
topic:
data-compare-topic: ${KAFKA_TOPIC_NAME}
data-compare-topic: data_comparing_email

aws:
region: ${AWS_REGION}
ses:
source-email: ${AWS_SES_SOURCE_EMAIL}
auth:
static:
key_id: ${AWS_KEY_ID:NA}
access_key: ${AWS_ACCESS_KEY:NA}
token: ${AWS_TOKEN:NA}
profile:
profile_name: ${AWS_PROFILE:NA}
iam:
enabled: ${AWS_IAM:false}
s3:
bucket-name: ${AWS_S3_BUCKET_NAME}
url-expiration-hours: 48
bucket-name: eq-data-compare
region: ${S3_REGION:NA}
url-expiration-hours: 48
ses:
source-email: [email protected]

0 comments on commit 94dec41

Please sign in to comment.