diff --git a/smallrye-reactive-messaging-rabbitmq/pom.xml b/smallrye-reactive-messaging-rabbitmq/pom.xml
index 776bb9db98..6c767b005c 100644
--- a/smallrye-reactive-messaging-rabbitmq/pom.xml
+++ b/smallrye-reactive-messaging-rabbitmq/pom.xml
@@ -63,7 +63,7 @@
org.slf4j
- slf4j-simple
+ slf4j-reload4j
test
@@ -77,6 +77,11 @@
${project.version}
test
+
+ org.testcontainers
+ toxiproxy
+ test
+
diff --git a/smallrye-reactive-messaging-rabbitmq/src/main/java/io/smallrye/reactive/messaging/rabbitmq/ClientHolder.java b/smallrye-reactive-messaging-rabbitmq/src/main/java/io/smallrye/reactive/messaging/rabbitmq/ClientHolder.java
index 020a334754..5c9ef286a2 100644
--- a/smallrye-reactive-messaging-rabbitmq/src/main/java/io/smallrye/reactive/messaging/rabbitmq/ClientHolder.java
+++ b/smallrye-reactive-messaging-rabbitmq/src/main/java/io/smallrye/reactive/messaging/rabbitmq/ClientHolder.java
@@ -32,32 +32,28 @@ public ClientHolder(RabbitMQClient client,
Context root) {
this.client = client;
this.vertx = vertx;
- this.connection = Uni.createFrom().voidItem()
- .onItem().transformToUni(unused -> {
- log.establishingConnection(configuration.getChannel());
- return client.start()
- .onSubscription().invoke(() -> {
- connected.set(true);
- log.connectionEstablished(configuration.getChannel());
- })
- .onItem().transform(ignored -> {
- connectionHolder
- .set(new CurrentConnection(client, root == null ? Vertx.currentContext() : root));
-
- // handle the case we are already disconnected.
- if (!client.isConnected() || connectionHolder.get() == null) {
- // Throwing the exception would trigger a retry.
- connectionHolder.set(null);
- throw ex.illegalStateConnectionDisconnected();
- }
- return client;
- })
- .onFailure().invoke(log::unableToConnectToBroker)
- .onFailure().invoke(t -> {
- connectionHolder.set(null);
- log.unableToRecoverFromConnectionDisruption(t);
- });
+ this.connection = Uni.createFrom().deferred(() -> client.start()
+ .onSubscription().invoke(() -> {
+ connected.set(true);
+ log.connectionEstablished(configuration.getChannel());
})
+ .onItem().transform(ignored -> {
+ connectionHolder
+ .set(new CurrentConnection(client, root == null ? Vertx.currentContext() : root));
+
+ // handle the case we are already disconnected.
+ if (!client.isConnected() || connectionHolder.get() == null) {
+ // Throwing the exception would trigger a retry.
+ connectionHolder.set(null);
+ throw ex.illegalStateConnectionDisconnected();
+ }
+ return client;
+ })
+ .onFailure().invoke(log::unableToConnectToBroker)
+ .onFailure().invoke(t -> {
+ connectionHolder.set(null);
+ log.unableToRecoverFromConnectionDisruption(t);
+ }))
.memoize().until(() -> {
CurrentConnection connection = connectionHolder.get();
if (connection == null) {
diff --git a/smallrye-reactive-messaging-rabbitmq/src/main/java/io/smallrye/reactive/messaging/rabbitmq/internals/IncomingRabbitMQChannel.java b/smallrye-reactive-messaging-rabbitmq/src/main/java/io/smallrye/reactive/messaging/rabbitmq/internals/IncomingRabbitMQChannel.java
index 64ef9390a4..c33539fca6 100644
--- a/smallrye-reactive-messaging-rabbitmq/src/main/java/io/smallrye/reactive/messaging/rabbitmq/internals/IncomingRabbitMQChannel.java
+++ b/smallrye-reactive-messaging-rabbitmq/src/main/java/io/smallrye/reactive/messaging/rabbitmq/internals/IncomingRabbitMQChannel.java
@@ -2,9 +2,13 @@
import static io.smallrye.reactive.messaging.rabbitmq.i18n.RabbitMQExceptions.ex;
import static io.smallrye.reactive.messaging.rabbitmq.i18n.RabbitMQLogging.log;
+import static io.smallrye.reactive.messaging.rabbitmq.internals.RabbitMQClientHelper.declareExchangeIfNeeded;
+import static io.smallrye.reactive.messaging.rabbitmq.internals.RabbitMQClientHelper.getExchangeName;
+import static io.smallrye.reactive.messaging.rabbitmq.internals.RabbitMQClientHelper.parseArguments;
import static io.smallrye.reactive.messaging.rabbitmq.internals.RabbitMQClientHelper.serverQueueName;
-import static io.smallrye.reactive.messaging.rabbitmq.internals.RabbitMQConsumerHelper.*;
+import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList;
@@ -294,4 +298,109 @@ public void terminate() {
}
}
+ /**
+ * Establish a DLQ, possibly establishing a DLX too
+ *
+ * @param client the {@link RabbitMQClient}
+ * @param ic the {@link RabbitMQConnectorIncomingConfiguration}
+ * @return a {@link Uni} containing the DLQ name
+ */
+ static Uni> configureDLQorDLX(final RabbitMQClient client, final RabbitMQConnectorIncomingConfiguration ic,
+ final Instance