Skip to content

Commit bbae486

Browse files
committed
GH-454 - Fix event externalization for RabbitMQ.
We now properly wrap the null value returned as a result from the RabbitMQ event externalization into a CompletableFuture. Tightened test case to prevent regressions going forward.
1 parent f98162a commit bbae486

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

spring-modulith-events/spring-modulith-events-amqp/src/main/java/org/springframework/modulith/events/amqp/RabbitEventExternalizerConfiguration.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023 the original author or authors.
2+
* Copyright 2023-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -15,6 +15,8 @@
1515
*/
1616
package org.springframework.modulith.events.amqp;
1717

18+
import java.util.concurrent.CompletableFuture;
19+
1820
import org.slf4j.Logger;
1921
import org.slf4j.LoggerFactory;
2022
import org.springframework.amqp.rabbit.core.RabbitMessageOperations;
@@ -63,7 +65,7 @@ DelegatingEventExternalizer rabbitEventExternalizer(EventExternalizationConfigur
6365

6466
operations.convertAndSend(routing.getTarget(), routing.getKey(payload), payload);
6567

66-
return null;
68+
return CompletableFuture.completedFuture(null);
6769
});
6870
}
6971
}

spring-modulith-events/spring-modulith-events-amqp/src/test/java/org/springframework/modulith/events/amqp/RabbitEventPublicationIntegrationTests.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023 the original author or authors.
2+
* Copyright 2023-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -32,6 +32,7 @@
3232
import org.springframework.context.ApplicationEventPublisher;
3333
import org.springframework.context.annotation.Bean;
3434
import org.springframework.modulith.events.ApplicationModuleListener;
35+
import org.springframework.modulith.events.CompletedEventPublications;
3536
import org.springframework.modulith.events.Externalized;
3637
import org.springframework.transaction.annotation.Transactional;
3738
import org.testcontainers.containers.RabbitMQContainer;
@@ -47,6 +48,7 @@ class RabbitEventPublicationIntegrationTests {
4748

4849
@Autowired TestPublisher publisher;
4950
@Autowired RabbitAdmin rabbit;
51+
@Autowired CompletedEventPublications completed;
5052

5153
@SpringBootApplication
5254
static class TestConfiguration {
@@ -87,6 +89,7 @@ void publishesEventToRabbitMq() throws Exception {
8789
var info = rabbit.getQueueInfo("queue");
8890

8991
assertThat(info.getMessageCount()).isEqualTo(1);
92+
assertThat(completed.findAll()).hasSize(1);
9093
}
9194

9295
@Externalized("target")

0 commit comments

Comments
 (0)