GH-438 - 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.
This commit is contained in:
Oliver Drotbohm
2024-01-16 19:16:36 +01:00
parent 1e71649073
commit a85a788ad2
2 changed files with 8 additions and 3 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2023 the original author or authors.
* Copyright 2023-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,6 +15,8 @@
*/
package org.springframework.modulith.events.amqp;
import java.util.concurrent.CompletableFuture;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.core.RabbitMessageOperations;
@@ -63,7 +65,7 @@ class RabbitEventExternalizerConfiguration {
operations.convertAndSend(routing.getTarget(), routing.getKey(payload), payload);
return null;
return CompletableFuture.completedFuture(null);
});
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2023 the original author or authors.
* Copyright 2023-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -32,6 +32,7 @@ import org.springframework.boot.testcontainers.service.connection.ServiceConnect
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.annotation.Bean;
import org.springframework.modulith.events.ApplicationModuleListener;
import org.springframework.modulith.events.CompletedEventPublications;
import org.springframework.modulith.events.Externalized;
import org.springframework.transaction.annotation.Transactional;
import org.testcontainers.containers.RabbitMQContainer;
@@ -47,6 +48,7 @@ class RabbitEventPublicationIntegrationTests {
@Autowired TestPublisher publisher;
@Autowired RabbitAdmin rabbit;
@Autowired CompletedEventPublications completed;
@SpringBootApplication
static class TestConfiguration {
@@ -87,6 +89,7 @@ class RabbitEventPublicationIntegrationTests {
var info = rabbit.getQueueInfo("queue");
assertThat(info.getMessageCount()).isEqualTo(1);
assertThat(completed.findAll()).hasSize(1);
}
@Externalized("target")