diff --git a/ab2d-events-client/src/main/java/gov/cms/ab2d/eventclient/clients/SQSConfig.java b/ab2d-events-client/src/main/java/gov/cms/ab2d/eventclient/clients/SQSConfig.java index d4e0c5e8..766beeda 100644 --- a/ab2d-events-client/src/main/java/gov/cms/ab2d/eventclient/clients/SQSConfig.java +++ b/ab2d-events-client/src/main/java/gov/cms/ab2d/eventclient/clients/SQSConfig.java @@ -9,10 +9,13 @@ import com.fasterxml.jackson.databind.jsontype.impl.LaissezFaireSubTypeValidator; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import gov.cms.ab2d.eventclient.config.Ab2dEnvironment; +import io.awspring.cloud.sqs.config.SqsBootstrapConfiguration; +import io.awspring.cloud.sqs.config.SqsMessageListenerContainerFactory; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Primary; import org.springframework.messaging.converter.MappingJackson2MessageConverter; import org.springframework.messaging.converter.MessageConverter; @@ -24,6 +27,7 @@ import java.net.URI; +@Import(SqsBootstrapConfiguration.class) @Configuration @Slf4j public class SQSConfig { @@ -49,6 +53,14 @@ public SQSConfig(@Value("${cloud.aws.region.static}") String region, System.setProperty("sqs.queue-name", sqsQueueName); } + @Bean + public SqsMessageListenerContainerFactory defaultSqsListenerContainerFactory() { + return SqsMessageListenerContainerFactory + .builder() + .sqsAsyncClient(amazonSQSAsync()) + .build(); + } + @Primary @Bean public SqsAsyncClient amazonSQSAsync() { @@ -60,6 +72,7 @@ public SqsAsyncClient amazonSQSAsync() { .region(Region.US_EAST_1) .build()); } + log.info("Creating SqsAsyncClient"); return SqsAsyncClient.builder() .credentialsProvider(DefaultCredentialsProvider.builder().build()) .region(Region.US_EAST_1) @@ -99,7 +112,7 @@ public SqsAsyncClient createQueue(SqsAsyncClient sqsClient) { .build(); sqsClient.createQueue(createQueueRequest); - log.info("Queue created"); + log.info("Queue created: " + sqsQueueName); } catch (SqsException e) { log.error(e.getMessage()); } diff --git a/ab2d-events-client/src/main/java/gov/cms/ab2d/eventclient/clients/SQSEventClient.java b/ab2d-events-client/src/main/java/gov/cms/ab2d/eventclient/clients/SQSEventClient.java index c1df09a9..df15a74c 100644 --- a/ab2d-events-client/src/main/java/gov/cms/ab2d/eventclient/clients/SQSEventClient.java +++ b/ab2d-events-client/src/main/java/gov/cms/ab2d/eventclient/clients/SQSEventClient.java @@ -36,12 +36,14 @@ public SQSEventClient(SqsAsyncClient amazonSQS, ObjectMapper mapper, String queu @Override public void sendLogs(LoggableEvent requestEvent) { + log.info("Send logs to queue: {}", queueName); GeneralSQSMessage sqsMessage = new GeneralSQSMessage(requestEvent); sendMessage(sqsMessage); } @Override public void alert(String message, List environments) { + log.info("Send alert to queue: {}", queueName); AlertSQSMessage sqsMessage = new AlertSQSMessage(message, environments); sendMessage(sqsMessage); } @@ -116,6 +118,7 @@ public void sendMessage(SQSMessages message) { .build(); amazonSQS.sendMessage(sendMessageRequest); + log.info("Sent message to queue: {}", queueUrl); } catch (JsonProcessingException | UnsupportedOperationException | SqsException e) { log.info(e.getMessage()); diff --git a/ab2d-events-client/src/test/java/gov/cms/ab2d/eventclient/config/SendSqsEventTest.java b/ab2d-events-client/src/test/java/gov/cms/ab2d/eventclient/config/SendSqsEventTest.java index 55f46fad..2b978a42 100644 --- a/ab2d-events-client/src/test/java/gov/cms/ab2d/eventclient/config/SendSqsEventTest.java +++ b/ab2d-events-client/src/test/java/gov/cms/ab2d/eventclient/config/SendSqsEventTest.java @@ -14,7 +14,6 @@ import java.util.ArrayList; import java.util.List; import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ExecutionException; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; diff --git a/build.gradle b/build.gradle index a1b4f98e..b203bf5f 100644 --- a/build.gradle +++ b/build.gradle @@ -26,7 +26,7 @@ ext { bfdVersion='3.2.0' aggregatorVersion='2.0.0' filtersVersion='2.1.0' - eventClientVersion='3.2.0' + eventClientVersion='3.2.1' propertiesClientVersion='2.0.0' contractClientVersion='2.0.0' snsClientVersion='1.0.0'