This version is still in development and is not considered stable yet. For the latest stable version, please use Spring AMQP 3.2.4!spring-doc.cn

RabbitMQ REST API

When the management plugin is enabled, the RabbitMQ server exposes a REST API to monitor and configure the broker. A Java Binding for the API is now provided. The com.rabbitmq.http.client.Client is a standard, immediate, and, therefore, blocking API. It is based on the Spring Web module and its RestTemplate implementation. On the other hand, the com.rabbitmq.http.client.ReactorNettyClient is a reactive, non-blocking implementation based on the Reactor Netty project.spring-doc.cn

Also, the management REST API can be used with any HTTP client. The next example demonstrates how to get a queue information using WebClient:spring-doc.cn

	public Map<String, Object> queueInfo(String queueName) throws URISyntaxException {
		WebClient client = createClient("admin", "admin");
		URI uri = queueUri(queueName);
		return client.get()
				.uri(uri)
				.accept(MediaType.APPLICATION_JSON)
				.retrieve()
				.bodyToMono(new ParameterizedTypeReference<Map<String, Object>>() {
				})
				.block(Duration.ofSeconds(10));
	}

	private URI queueUri(String queue) throws URISyntaxException {
		URI uri = new URI("http://localhost:15672/api/")
				.resolve("/api/queues/" + UriUtils.encodePathSegment("/", StandardCharsets.UTF_8) + "/" + queue);
		return uri;
	}

	private WebClient createClient(String adminUser, String adminPassword) {
		return WebClient.builder()
				.filter(ExchangeFilterFunctions.basicAuthentication(adminUser, adminPassword))
				.build();
	}