From e8898c1da1b8a3c4d9e3d99afc4226a31eced911 Mon Sep 17 00:00:00 2001 From: Oliver Drotbohm Date: Tue, 31 Oct 2023 23:32:06 +0100 Subject: [PATCH] GH-344 - Polishing. Switch to DelegatingEventExternalizer APIs changed to return CompletableFuture. Imports, formatting. Drop dependencies not needed. --- pom.xml | 1 + .../spring-modulith-events-aws-sns/pom.xml | 6 - .../SnsEventExternalizerConfiguration.java | 22 +- .../modulith/events/aws/sns/package-info.java | 2 +- ...rnalizerConfigurationIntegrationTests.java | 12 +- .../SnsEventPublicationIntegrationTests.java | 249 +++++++++--------- .../spring-modulith-events-aws-sqs/pom.xml | 6 - .../SqsEventExternalizerConfiguration.java | 11 +- .../modulith/events/aws/sqs/package-info.java | 2 +- ...rnalizerConfigurationIntegrationTests.java | 12 +- .../SqsEventPublicationIntegrationTests.java | 33 ++- .../spring-modulith-events-core/pom.xml | 2 +- 12 files changed, 172 insertions(+), 186 deletions(-) diff --git a/pom.xml b/pom.xml index 9bb4b4e4..8aaccc37 100644 --- a/pom.xml +++ b/pom.xml @@ -43,6 +43,7 @@ 6.1.0-RC1 3.2.0-RC1 3.0.2 + diff --git a/spring-modulith-events/spring-modulith-events-aws-sns/pom.xml b/spring-modulith-events/spring-modulith-events-aws-sns/pom.xml index 0454d680..ae835cf1 100644 --- a/spring-modulith-events/spring-modulith-events-aws-sns/pom.xml +++ b/spring-modulith-events/spring-modulith-events-aws-sns/pom.xml @@ -34,12 +34,6 @@ spring-cloud-aws-sns - - com.fasterxml.jackson.core - jackson-databind - true - - diff --git a/spring-modulith-events/spring-modulith-events-aws-sns/src/main/java/org/springframework/modulith/events/aws/sns/SnsEventExternalizerConfiguration.java b/spring-modulith-events/spring-modulith-events-aws-sns/src/main/java/org/springframework/modulith/events/aws/sns/SnsEventExternalizerConfiguration.java index fee0e5ad..c356a86b 100644 --- a/spring-modulith-events/spring-modulith-events-aws-sns/src/main/java/org/springframework/modulith/events/aws/sns/SnsEventExternalizerConfiguration.java +++ b/spring-modulith-events/spring-modulith-events-aws-sns/src/main/java/org/springframework/modulith/events/aws/sns/SnsEventExternalizerConfiguration.java @@ -18,10 +18,11 @@ import io.awspring.cloud.sns.core.SnsNotification; import io.awspring.cloud.sns.core.SnsOperations; import io.awspring.cloud.sns.core.SnsTemplate; + +import java.util.concurrent.CompletableFuture; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import software.amazon.awssdk.services.sns.model.InvalidParameterException; - import org.springframework.beans.factory.BeanFactory; import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.autoconfigure.AutoConfigureAfter; @@ -30,7 +31,6 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.expression.BeanFactoryResolver; import org.springframework.expression.spel.support.StandardEvaluationContext; -import org.springframework.messaging.MessageDeliveryException; import org.springframework.modulith.events.EventExternalizationConfiguration; import org.springframework.modulith.events.config.EventExternalizationAutoConfiguration; import org.springframework.modulith.events.support.BrokerRouting; @@ -40,6 +40,7 @@ * Auto-configuration to set up a {@link DelegatingEventExternalizer} to externalize events to SNS. * * @author Maciej Walkowiak + * @author Oliver Drotbohm * @since 1.1 */ @AutoConfiguration @@ -64,22 +65,17 @@ DelegatingEventExternalizer snsEventExternalizer(EventExternalizationConfigurati return new DelegatingEventExternalizer(configuration, (target, payload) -> { var routing = BrokerRouting.of(target, context); - var builder = SnsNotification.builder(payload); var key = routing.getKey(payload); + // when routing key is set, SNS topic must be a FIFO topic if (key != null) { builder.groupId(key); } - try { - operations.sendNotification(routing.getTarget(), builder.build()); - } catch (MessageDeliveryException e) { - // message delivery may fail if groupId is set and topic is not a FIFO topic, or content based deduplication has not been set on topic attributes. - if (e.getCause() instanceof InvalidParameterException) { - logger.error("Failed to send notification to SNS topic {}:{}", routing.getTarget(), e.getCause().getMessage()); - } - throw e; - } + + operations.sendNotification(routing.getTarget(), builder.build()); + + return CompletableFuture.completedFuture(null); }); } } diff --git a/spring-modulith-events/spring-modulith-events-aws-sns/src/main/java/org/springframework/modulith/events/aws/sns/package-info.java b/spring-modulith-events/spring-modulith-events-aws-sns/src/main/java/org/springframework/modulith/events/aws/sns/package-info.java index 4b089111..5d6526cf 100644 --- a/spring-modulith-events/spring-modulith-events-aws-sns/src/main/java/org/springframework/modulith/events/aws/sns/package-info.java +++ b/spring-modulith-events/spring-modulith-events-aws-sns/src/main/java/org/springframework/modulith/events/aws/sns/package-info.java @@ -1,5 +1,5 @@ /** - * SNS event externalization support. + * AWS SNS event externalization support. */ @org.springframework.lang.NonNullApi package org.springframework.modulith.events.aws.sns; diff --git a/spring-modulith-events/spring-modulith-events-aws-sns/src/test/java/org/springframework/modulith/events/aws/sns/SnsEventExternalizerConfigurationIntegrationTests.java b/spring-modulith-events/spring-modulith-events-aws-sns/src/test/java/org/springframework/modulith/events/aws/sns/SnsEventExternalizerConfigurationIntegrationTests.java index 3469eda1..421eefe5 100644 --- a/spring-modulith-events/spring-modulith-events-aws-sns/src/test/java/org/springframework/modulith/events/aws/sns/SnsEventExternalizerConfigurationIntegrationTests.java +++ b/spring-modulith-events/spring-modulith-events-aws-sns/src/test/java/org/springframework/modulith/events/aws/sns/SnsEventExternalizerConfigurationIntegrationTests.java @@ -15,17 +15,17 @@ */ package org.springframework.modulith.events.aws.sns; +import static org.assertj.core.api.Assertions.*; +import static org.mockito.Mockito.*; + import io.awspring.cloud.sns.core.SnsOperations; -import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.test.context.runner.ApplicationContextRunner; import org.springframework.modulith.events.EventExternalizationConfiguration; import org.springframework.modulith.events.support.DelegatingEventExternalizer; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; - /** * Integration tests for {@link SnsEventExternalizerConfiguration}. * @@ -34,7 +34,7 @@ */ class SnsEventExternalizerConfigurationIntegrationTests { - @Test // GH-342 + @Test // GH-344 void registersExternalizerByDefault() { basicSetup() @@ -43,7 +43,7 @@ void registersExternalizerByDefault() { }); } - @Test // GH-342 + @Test // GH-344 void disablesExternalizationIfConfigured() { basicSetup() diff --git a/spring-modulith-events/spring-modulith-events-aws-sns/src/test/java/org/springframework/modulith/events/aws/sns/SnsEventPublicationIntegrationTests.java b/spring-modulith-events/spring-modulith-events-aws-sns/src/test/java/org/springframework/modulith/events/aws/sns/SnsEventPublicationIntegrationTests.java index ad7fec33..0efa809b 100644 --- a/spring-modulith-events/spring-modulith-events-aws-sns/src/test/java/org/springframework/modulith/events/aws/sns/SnsEventPublicationIntegrationTests.java +++ b/spring-modulith-events/spring-modulith-events-aws-sns/src/test/java/org/springframework/modulith/events/aws/sns/SnsEventPublicationIntegrationTests.java @@ -15,16 +15,18 @@ */ package org.springframework.modulith.events.aws.sns; -import java.util.Map; +import static org.assertj.core.api.Assertions.*; +import static org.awaitility.Awaitility.*; import lombok.RequiredArgsConstructor; -import org.junit.jupiter.api.Test; -import org.testcontainers.containers.localstack.LocalStackContainer; -import org.testcontainers.utility.DockerImageName; +import lombok.Value; import software.amazon.awssdk.services.sns.SnsClient; import software.amazon.awssdk.services.sqs.SqsAsyncClient; import software.amazon.awssdk.services.sqs.model.QueueAttributeName; +import java.util.Map; + +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.test.context.SpringBootTest; @@ -34,137 +36,132 @@ import org.springframework.modulith.events.Externalized; import org.springframework.test.context.DynamicPropertyRegistry; import org.springframework.transaction.annotation.Transactional; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.awaitility.Awaitility.await; +import org.testcontainers.containers.localstack.LocalStackContainer; +import org.testcontainers.utility.DockerImageName; /** * Integration tests for SQS-based event publication. * * @author Maciej Walkowiak + * @author Oliver Drotbohm */ @SpringBootTest class SnsEventPublicationIntegrationTests { - @Autowired TestPublisher publisher; - @Autowired SnsClient snsClient; - @Autowired SqsAsyncClient sqsAsyncClient; - - @SpringBootApplication - static class TestConfiguration { - - @Bean - LocalStackContainer localStackContainer(DynamicPropertyRegistry registry) { - var localstack = new LocalStackContainer(DockerImageName.parse("localstack/localstack:2.3.2")); - registry.add("spring.cloud.aws.endpoint", localstack::getEndpoint); - registry.add("spring.cloud.aws.credentials.access-key", localstack::getAccessKey); - registry.add("spring.cloud.aws.credentials.secret-key", localstack::getSecretKey); - registry.add("spring.cloud.aws.region.static", localstack::getRegion); - return localstack; - } + @Autowired TestPublisher publisher; + @Autowired SnsClient snsClient; + @Autowired SqsAsyncClient sqsAsyncClient; + + @SpringBootApplication + static class TestConfiguration { + + @Bean + LocalStackContainer localStackContainer(DynamicPropertyRegistry registry) { + + var localstack = new LocalStackContainer(DockerImageName.parse("localstack/localstack:2.3.2")); + + registry.add("spring.cloud.aws.endpoint", localstack::getEndpoint); + registry.add("spring.cloud.aws.credentials.access-key", localstack::getAccessKey); + registry.add("spring.cloud.aws.credentials.secret-key", localstack::getSecretKey); + registry.add("spring.cloud.aws.region.static", localstack::getRegion); + + return localstack; + } + + @Bean + TestPublisher testPublisher(ApplicationEventPublisher publisher) { + return new TestPublisher(publisher); + } + + @Bean + TestListener testListener() { + return new TestListener(); + } + } + + @Test // GH-344 + void publishesEventToSns() { + + var topicArn = snsClient.createTopic(request -> request.name("target")).topicArn(); + + var queueUrl = sqsAsyncClient.createQueue(request -> request.queueName("queue")) + .join() + .queueUrl(); + + var queueArn = sqsAsyncClient + .getQueueAttributes(r -> r.queueUrl(queueUrl).attributeNames(QueueAttributeName.QUEUE_ARN)) + .join().attributes().get(QueueAttributeName.QUEUE_ARN); + + snsClient.subscribe(r -> r.topicArn(topicArn).protocol("sqs").endpoint(queueArn)); + + publisher.publishEvent(); + + await().untilAsserted(() -> { + + var response = sqsAsyncClient.receiveMessage(r -> r.queueUrl(queueUrl)).join(); + + assertThat(response.hasMessages()).isTrue(); + }); + } + + @Test // GH-344 + void publishesEventWithGroupIdToSns() { + + var topicArn = snsClient.createTopic(request -> request.name("target.fifo") + .attributes(Map.of( + "FifoTopic", "true", + "ContentBasedDeduplication", "true"))) + .topicArn(); + + var queueUrl = sqsAsyncClient.createQueue(request -> request.queueName("queue.fifo") + .attributes(Map.of(QueueAttributeName.FIFO_QUEUE, "true"))) + .join() + .queueUrl(); + + var queueArn = sqsAsyncClient + .getQueueAttributes(r -> r.queueUrl(queueUrl).attributeNames(QueueAttributeName.QUEUE_ARN)) + .join().attributes().get(QueueAttributeName.QUEUE_ARN); + snsClient.subscribe(r -> r.topicArn(topicArn).protocol("sqs").endpoint(queueArn)); + + publisher.publishEventWithKey(); + + await().untilAsserted(() -> { + var response = sqsAsyncClient.receiveMessage(r -> r.queueUrl(queueUrl)).join(); + assertThat(response.hasMessages()).isTrue(); + }); + } + + @Externalized("target") + static class TestEvent {} + + @Value + @Externalized("target.fifo::#{getKey()}") + static class TestEventWithKey { + String key; + } + + @RequiredArgsConstructor + static class TestPublisher { + + private final ApplicationEventPublisher events; + + @Transactional + void publishEvent() { + events.publishEvent(new TestEvent()); + } + + @Transactional + void publishEventWithKey() { + events.publishEvent(new TestEventWithKey("aKey")); + } + } + + static class TestListener { - @Bean - TestPublisher testPublisher(ApplicationEventPublisher publisher) { - return new TestPublisher(publisher); - } - - @Bean - TestListener testListener() { - return new TestListener(); - } - } - - @Test - void publishesEventToSns() { - - var topicArn = snsClient.createTopic(request -> request.name("target")).topicArn(); - - var queueUrl = sqsAsyncClient.createQueue(request -> request.queueName("queue")) - .join() - .queueUrl(); - - var queueArn = sqsAsyncClient - .getQueueAttributes(r -> r.queueUrl(queueUrl).attributeNames(QueueAttributeName.QUEUE_ARN)) - .join().attributes().get(QueueAttributeName.QUEUE_ARN); - snsClient.subscribe(r -> r.topicArn(topicArn).protocol("sqs").endpoint(queueArn)); - - publisher.publishEvent(); - - await().untilAsserted(() -> { - var response = sqsAsyncClient.receiveMessage(r -> r.queueUrl(queueUrl)).join(); - - assertThat(response.hasMessages()).isTrue(); - }); - } - - @Test - void publishesEventWithGroupIdToSns() { - - var topicArn = snsClient.createTopic(request -> request.name("target.fifo") - .attributes(Map.of( - "FifoTopic", "true", - "ContentBasedDeduplication", "true" - ))) - .topicArn(); - - var queueUrl = sqsAsyncClient.createQueue(request -> request.queueName("queue.fifo") - .attributes(Map.of(QueueAttributeName.FIFO_QUEUE, "true"))) - .join() - .queueUrl(); - - var queueArn = sqsAsyncClient - .getQueueAttributes(r -> r.queueUrl(queueUrl).attributeNames(QueueAttributeName.QUEUE_ARN)) - .join().attributes().get(QueueAttributeName.QUEUE_ARN); - snsClient.subscribe(r -> r.topicArn(topicArn).protocol("sqs").endpoint(queueArn)); - - publisher.publishEventWithKey(); - - await().untilAsserted(() -> { - var response = sqsAsyncClient.receiveMessage(r -> r.queueUrl(queueUrl)).join(); - assertThat(response.hasMessages()).isTrue(); - }); - } - - @Externalized("target") - static class TestEvent { } - - @Externalized("target.fifo::#{getKey()}") - static class TestEventWithKey { - private final String key; - - TestEventWithKey(String key) { - this.key = key; - } - - public String getKey() { - return key; - } - } - - @RequiredArgsConstructor - static class TestPublisher { - - private final ApplicationEventPublisher events; - - @Transactional - void publishEvent() { - events.publishEvent(new TestEvent()); - } - - @Transactional - void publishEventWithKey() { - events.publishEvent(new TestEventWithKey("aKey")); - } - } - - static class TestListener { - - @ApplicationModuleListener - void on(TestEvent event) { - } + @ApplicationModuleListener + void on(TestEvent event) {} - @ApplicationModuleListener - void on(TestEventWithKey event) { - } - } + @ApplicationModuleListener + void on(TestEventWithKey event) {} + } } diff --git a/spring-modulith-events/spring-modulith-events-aws-sqs/pom.xml b/spring-modulith-events/spring-modulith-events-aws-sqs/pom.xml index 7bd4b8f7..f72f797f 100644 --- a/spring-modulith-events/spring-modulith-events-aws-sqs/pom.xml +++ b/spring-modulith-events/spring-modulith-events-aws-sqs/pom.xml @@ -34,12 +34,6 @@ spring-cloud-aws-sqs - - com.fasterxml.jackson.core - jackson-databind - true - - diff --git a/spring-modulith-events/spring-modulith-events-aws-sqs/src/main/java/org/springframework/modulith/events/aws/sqs/SqsEventExternalizerConfiguration.java b/spring-modulith-events/spring-modulith-events-aws-sqs/src/main/java/org/springframework/modulith/events/aws/sqs/SqsEventExternalizerConfiguration.java index 87b46ca4..f9361673 100644 --- a/spring-modulith-events/spring-modulith-events-aws-sqs/src/main/java/org/springframework/modulith/events/aws/sqs/SqsEventExternalizerConfiguration.java +++ b/spring-modulith-events/spring-modulith-events-aws-sqs/src/main/java/org/springframework/modulith/events/aws/sqs/SqsEventExternalizerConfiguration.java @@ -17,9 +17,11 @@ import io.awspring.cloud.sqs.operations.SqsOperations; import io.awspring.cloud.sqs.operations.SqsTemplate; + +import java.util.concurrent.CompletableFuture; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; - import org.springframework.beans.factory.BeanFactory; import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.autoconfigure.AutoConfigureAfter; @@ -37,6 +39,7 @@ * Auto-configuration to set up a {@link DelegatingEventExternalizer} to externalize events to SQS. * * @author Maciej Walkowiak + * @author Oliver Drotbohm * @since 1.1 */ @AutoConfiguration @@ -62,13 +65,15 @@ DelegatingEventExternalizer sqsEventExternalizer(EventExternalizationConfigurati var routing = BrokerRouting.of(target, context); - operations.send(sqsSendOptions -> { + return CompletableFuture.completedFuture(operations.send(sqsSendOptions -> { + var options = sqsSendOptions.queue(routing.getTarget()).payload(payload); var key = routing.getKey(payload); + if (key != null) { options.messageGroupId(key); } - }); + })); }); } } diff --git a/spring-modulith-events/spring-modulith-events-aws-sqs/src/main/java/org/springframework/modulith/events/aws/sqs/package-info.java b/spring-modulith-events/spring-modulith-events-aws-sqs/src/main/java/org/springframework/modulith/events/aws/sqs/package-info.java index f914b12a..2e5094e3 100644 --- a/spring-modulith-events/spring-modulith-events-aws-sqs/src/main/java/org/springframework/modulith/events/aws/sqs/package-info.java +++ b/spring-modulith-events/spring-modulith-events-aws-sqs/src/main/java/org/springframework/modulith/events/aws/sqs/package-info.java @@ -1,5 +1,5 @@ /** - * SQS event externalization support. + * AWS SQS event externalization support. */ @org.springframework.lang.NonNullApi package org.springframework.modulith.events.aws.sqs; diff --git a/spring-modulith-events/spring-modulith-events-aws-sqs/src/test/java/org/springframework/modulith/events/aws/sqs/SqsEventExternalizerConfigurationIntegrationTests.java b/spring-modulith-events/spring-modulith-events-aws-sqs/src/test/java/org/springframework/modulith/events/aws/sqs/SqsEventExternalizerConfigurationIntegrationTests.java index 40e19f46..12f44922 100644 --- a/spring-modulith-events/spring-modulith-events-aws-sqs/src/test/java/org/springframework/modulith/events/aws/sqs/SqsEventExternalizerConfigurationIntegrationTests.java +++ b/spring-modulith-events/spring-modulith-events-aws-sqs/src/test/java/org/springframework/modulith/events/aws/sqs/SqsEventExternalizerConfigurationIntegrationTests.java @@ -15,17 +15,17 @@ */ package org.springframework.modulith.events.aws.sqs; +import static org.assertj.core.api.Assertions.*; +import static org.mockito.Mockito.*; + import io.awspring.cloud.sqs.operations.SqsOperations; -import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.test.context.runner.ApplicationContextRunner; import org.springframework.modulith.events.EventExternalizationConfiguration; import org.springframework.modulith.events.support.DelegatingEventExternalizer; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; - /** * Integration tests for {@link SqsEventExternalizerConfiguration}. * @@ -34,7 +34,7 @@ */ class SqsEventExternalizerConfigurationIntegrationTests { - @Test // GH-342 + @Test // GH-344 void registersExternalizerByDefault() { basicSetup() @@ -43,7 +43,7 @@ void registersExternalizerByDefault() { }); } - @Test // GH-342 + @Test // GH-344 void disablesExternalizationIfConfigured() { basicSetup() diff --git a/spring-modulith-events/spring-modulith-events-aws-sqs/src/test/java/org/springframework/modulith/events/aws/sqs/SqsEventPublicationIntegrationTests.java b/spring-modulith-events/spring-modulith-events-aws-sqs/src/test/java/org/springframework/modulith/events/aws/sqs/SqsEventPublicationIntegrationTests.java index 468d9866..a615025a 100644 --- a/spring-modulith-events/spring-modulith-events-aws-sqs/src/test/java/org/springframework/modulith/events/aws/sqs/SqsEventPublicationIntegrationTests.java +++ b/spring-modulith-events/spring-modulith-events-aws-sqs/src/test/java/org/springframework/modulith/events/aws/sqs/SqsEventPublicationIntegrationTests.java @@ -15,15 +15,17 @@ */ package org.springframework.modulith.events.aws.sqs; -import java.util.Map; +import static org.assertj.core.api.Assertions.*; +import static org.awaitility.Awaitility.*; import lombok.RequiredArgsConstructor; -import org.junit.jupiter.api.Test; -import org.testcontainers.containers.localstack.LocalStackContainer; -import org.testcontainers.utility.DockerImageName; +import lombok.Value; import software.amazon.awssdk.services.sqs.SqsAsyncClient; import software.amazon.awssdk.services.sqs.model.QueueAttributeName; +import java.util.Map; + +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.test.context.SpringBootTest; @@ -33,14 +35,15 @@ import org.springframework.modulith.events.Externalized; import org.springframework.test.context.DynamicPropertyRegistry; import org.springframework.transaction.annotation.Transactional; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.awaitility.Awaitility.await; +import org.testcontainers.containers.localstack.LocalStackContainer; +import org.testcontainers.utility.DockerImageName; /** * Integration tests for SQS-based event publication. * * @author Maciej Walkowiak + * @author Oliver Drotbohm + * @since 1.1 */ @SpringBootTest class SqsEventPublicationIntegrationTests { @@ -53,11 +56,14 @@ static class TestConfiguration { @Bean LocalStackContainer localStackContainer(DynamicPropertyRegistry registry) { + var localstack = new LocalStackContainer(DockerImageName.parse("localstack/localstack:2.3.2")); + registry.add("spring.cloud.aws.endpoint", localstack::getEndpoint); registry.add("spring.cloud.aws.credentials.access-key", localstack::getAccessKey); registry.add("spring.cloud.aws.credentials.secret-key", localstack::getSecretKey); registry.add("spring.cloud.aws.region.static", localstack::getRegion); + return localstack; } @@ -92,7 +98,7 @@ void publishesEventToSqs() throws Exception { void publishesEventWithGroupIdToSqs() throws Exception { var queueUrl = sqsAsyncClient.createQueue(request -> request.queueName("target.fifo") - .attributes(Map.of(QueueAttributeName.FIFO_QUEUE, "true"))) + .attributes(Map.of(QueueAttributeName.FIFO_QUEUE, "true"))) .join() .queueUrl(); @@ -108,17 +114,10 @@ void publishesEventWithGroupIdToSqs() throws Exception { @Externalized("target") static class TestEvent {} + @Value @Externalized("target.fifo::#{getKey()}") static class TestEventWithKey { - private final String key; - - TestEventWithKey(String key) { - this.key = key; - } - - public String getKey() { - return key; - } + String key; } @RequiredArgsConstructor diff --git a/spring-modulith-events/spring-modulith-events-core/pom.xml b/spring-modulith-events/spring-modulith-events-core/pom.xml index efcdf614..ecfff7b9 100644 --- a/spring-modulith-events/spring-modulith-events-core/pom.xml +++ b/spring-modulith-events/spring-modulith-events-core/pom.xml @@ -15,7 +15,7 @@ org.springframework.modulith.events.core - +