Skip to content

Commit 063ae66

Browse files
committed
Fix management-rest-api.adoc for http-client
There is no `com.rabbitmq:http-client` (Hop) dependency anymore. The `WebClient` is used internally in the project for tests. Mention `WebClient` sample in the doc instead. * Fix `broker-configuration.adoc` for the `RabbitAdmin.getQueueInfo()` API
1 parent 8be6913 commit 063ae66

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed

src/reference/antora/modules/ROOT/pages/amqp/broker-configuration.adoc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ public interface AmqpAdmin {
3737
3838
Properties getQueueProperties(String queueName);
3939
40+
QueueInformation getQueueInfo(String queueName);
41+
4042
}
4143
----
4244

@@ -45,7 +47,7 @@ See also xref:amqp/template.adoc#scoped-operations[Scoped Operations].
4547
The `getQueueProperties()` method returns some limited information about the queue (message count and consumer count).
4648
The keys for the properties returned are available as constants in the `RabbitAdmin` (`QUEUE_NAME`,
4749
`QUEUE_MESSAGE_COUNT`, and `QUEUE_CONSUMER_COUNT`).
48-
The xref:amqp/management-rest-api.adoc#management-rest-api[RabbitMQ REST API] provides much more information in the `QueueInfo` object.
50+
The `getQueueInfo()` returns a convenient `QueueInformation` data object.
4951

5052
The no-arg `declareQueue()` method defines a queue on the broker with a name that is automatically generated.
5153
The additional properties of this auto-generated queue are `exclusive=true`, `autoDelete=true`, and `durable=false`.

src/reference/antora/modules/ROOT/pages/amqp/management-rest-api.adoc

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,32 @@ The `com.rabbitmq.http.client.Client` is a standard, immediate, and, therefore,
88
It is based on the {spring-framework-docs}/web.html[Spring Web] module and its `RestTemplate` implementation.
99
On the other hand, the `com.rabbitmq.http.client.ReactorNettyClient` is a reactive, non-blocking implementation based on the https://projectreactor.io/docs/netty/release/reference/docs/index.html[Reactor Netty] project.
1010

11-
The hop dependency (`com.rabbitmq:http-client`) is now also `optional`.
11+
Also, the https://www.rabbitmq.com/docs/management#http-api-endpoints[management REST API] can be used with any HTTP client.
12+
The next example demonstrates how to get a queue information using {spring-framework-docs}/web/webflux-webclient.html[WebClient]:
1213

13-
See their Javadoc for more information.
14+
[source,java]
15+
----
16+
public Map<String, Object> queueInfo(String queueName) throws URISyntaxException {
17+
WebClient client = createClient("admin", "admin");
18+
URI uri = queueUri(queueName);
19+
return client.get()
20+
.uri(uri)
21+
.accept(MediaType.APPLICATION_JSON)
22+
.retrieve()
23+
.bodyToMono(new ParameterizedTypeReference<Map<String, Object>>() {
24+
})
25+
.block(Duration.ofSeconds(10));
26+
}
1427
28+
private URI queueUri(String queue) throws URISyntaxException {
29+
URI uri = new URI("http://localhost:15672/api/")
30+
.resolve("/api/queues/" + UriUtils.encodePathSegment("/", StandardCharsets.UTF_8) + "/" + queue);
31+
return uri;
32+
}
33+
34+
private WebClient createClient(String adminUser, String adminPassword) {
35+
return WebClient.builder()
36+
.filter(ExchangeFilterFunctions.basicAuthentication(adminUser, adminPassword))
37+
.build();
38+
}
39+
----

0 commit comments

Comments
 (0)