diff --git a/binders/rabbit-binder/spring-cloud-stream-binder-rabbit-core/pom.xml b/binders/rabbit-binder/spring-cloud-stream-binder-rabbit-core/pom.xml
index b3d24ec9d..8203d1462 100644
--- a/binders/rabbit-binder/spring-cloud-stream-binder-rabbit-core/pom.xml
+++ b/binders/rabbit-binder/spring-cloud-stream-binder-rabbit-core/pom.xml
@@ -47,13 +47,22 @@
test
- org.apache.httpcomponents
- httpclient
+ org.springframework.boot
+ spring-boot-starter-webflux
- com.rabbitmq
- http-client
- 2.1.0.RELEASE
+ io.projectreactor.netty
+ reactor-netty
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+ io.projectreactor
+ reactor-test
+ test
diff --git a/binders/rabbit-binder/spring-cloud-stream-binder-rabbit-core/src/main/java/org/springframework/cloud/stream/binder/rabbit/admin/RabbitBindingCleaner.java b/binders/rabbit-binder/spring-cloud-stream-binder-rabbit-core/src/main/java/org/springframework/cloud/stream/binder/rabbit/admin/RabbitBindingCleaner.java
index 13c239a0b..d1e0dcf78 100644
--- a/binders/rabbit-binder/spring-cloud-stream-binder-rabbit-core/src/main/java/org/springframework/cloud/stream/binder/rabbit/admin/RabbitBindingCleaner.java
+++ b/binders/rabbit-binder/spring-cloud-stream-binder-rabbit-core/src/main/java/org/springframework/cloud/stream/binder/rabbit/admin/RabbitBindingCleaner.java
@@ -16,8 +16,10 @@
package org.springframework.cloud.stream.binder.rabbit.admin;
-import java.net.MalformedURLException;
+import java.net.URI;
import java.net.URISyntaxException;
+import java.nio.charset.StandardCharsets;
+import java.time.Duration;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
@@ -26,15 +28,15 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.stream.Collectors;
-import com.rabbitmq.http.client.Client;
-import com.rabbitmq.http.client.domain.BindingInfo;
-import com.rabbitmq.http.client.domain.ExchangeInfo;
-import com.rabbitmq.http.client.domain.QueueInfo;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.cloud.stream.binder.AbstractBinder;
import org.springframework.cloud.stream.binder.BindingCleaner;
+import org.springframework.core.ParameterizedTypeReference;
+import org.springframework.web.reactive.function.client.ExchangeFilterFunctions;
+import org.springframework.web.reactive.function.client.WebClient;
+import org.springframework.web.util.UriUtils;
/**
* Implementation of {@link org.springframework.cloud.stream.binder.BindingCleaner} for
@@ -65,28 +67,31 @@ public class RabbitBindingCleaner implements BindingCleaner {
String vhost, String binderPrefix, String entity, boolean isJob) {
try {
- Client client = new Client(adminUri, user, pw);
- return doClean(client,
+ WebClient client = WebClient.builder()
+ .filter(ExchangeFilterFunctions.basicAuthentication(user, pw))
+ .build();
+ URI uri = new URI(adminUri);
+ return doClean(client, uri,
vhost == null ? "/" : vhost,
binderPrefix == null ? BINDER_PREFIX : binderPrefix, entity, isJob);
}
- catch (MalformedURLException | URISyntaxException e) {
+ catch (URISyntaxException e) {
throw new RabbitAdminException("Couldn't create a Client", e);
}
}
- private Map> doClean(Client client,
- String vhost, String binderPrefix, String entity, boolean isJob) {
+ private Map> doClean(WebClient client,
+ URI uri, String vhost, String binderPrefix, String entity, boolean isJob) {
LinkedList removedQueues = isJob ? null
- : findStreamQueues(client, vhost, binderPrefix, entity);
- List removedExchanges = findExchanges(client, vhost, binderPrefix, entity);
+ : findStreamQueues(client, uri, vhost, binderPrefix, entity);
+ List removedExchanges = findExchanges(client, uri, vhost, binderPrefix, entity);
// Delete the queues in reverse order to enable re-running after a partial
// success.
// The queue search above starts with 0 and terminates on a not found.
if (removedQueues != null) {
removedQueues.descendingIterator().forEachRemaining(q -> {
- client.deleteQueue(vhost, q);
+ deleteQueue(client, uri, vhost, q);
if (logger.isDebugEnabled()) {
logger.debug("deleted queue: " + q);
}
@@ -98,7 +103,7 @@ public class RabbitBindingCleaner implements BindingCleaner {
}
// Fanout exchanges for taps
removedExchanges.forEach(exchange -> {
- client.deleteExchange(vhost, exchange);
+ deleteExchange(client, uri, vhost, exchange);
if (logger.isDebugEnabled()) {
logger.debug("deleted exchange: " + exchange);
}
@@ -109,15 +114,48 @@ public class RabbitBindingCleaner implements BindingCleaner {
return results;
}
- private LinkedList findStreamQueues(Client client, String vhost, String binderPrefix, String stream) {
+ private void deleteQueue(WebClient client, URI uri, String vhost, String q) {
+ URI deleteURI = uri
+ .resolve("/api/queues/" + UriUtils.encodePathSegment(vhost, StandardCharsets.UTF_8) + "/" + q);
+ client.delete()
+ .uri(deleteURI)
+ .retrieve()
+ .toEntity(Void.class)
+ .block(Duration.ofSeconds(10));
+ }
+
+ private void deleteExchange(WebClient client, URI uri, String vhost, String ex) {
+ URI deleteURI = uri
+ .resolve("/api/exchanges/" + UriUtils.encodePathSegment(vhost, StandardCharsets.UTF_8) + "/" + ex);
+ client.delete()
+ .uri(deleteURI)
+ .retrieve()
+ .toEntity(Void.class)
+ .block(Duration.ofSeconds(10));
+ }
+
+ private LinkedList findStreamQueues(WebClient client, URI uri, String vhost, String binderPrefix,
+ String stream) {
+
String queueNamePrefix = adjustPrefix(AbstractBinder.applyPrefix(binderPrefix, stream));
- List queues = client.getQueues(vhost);
+ List