Use convenient arguments() API the RabbitAmqpAdmin

Now `Management.ExchangeSpecification` and `Management.QueueSpecification` expose `arguments(Map<String, Object>)` API

Related to: https://github.com/rabbitmq/rabbitmq-amqp-java-client/issues/153
This commit is contained in:
Artem Bilan
2025-03-17 17:07:35 -04:00
parent d6ded3fca2
commit 589baa634d
2 changed files with 4 additions and 13 deletions

View File

@@ -18,8 +18,6 @@ package org.springframework.amqp.core;
import java.util.Map;
import org.jspecify.annotations.Nullable;
/**
* Interface for all exchanges.
*
@@ -63,7 +61,6 @@ public interface Exchange extends Declarable {
*
* @return the arguments.
*/
@Nullable
Map<String, Object> getArguments();
/**

View File

@@ -19,7 +19,6 @@ package org.springframework.amqp.rabbitmq.client;
import java.io.IOException;
import java.util.Collection;
import java.util.LinkedList;
import java.util.Map;
import java.util.Objects;
import java.util.Properties;
import java.util.concurrent.atomic.AtomicReference;
@@ -281,13 +280,10 @@ public class RabbitAmqpAdmin
Management.ExchangeSpecification exchangeSpecification =
management.exchange(exchange.getName())
.type(exchange.isDelayed() ? RabbitAdmin.DELAYED_MESSAGE_EXCHANGE : exchange.getType())
// .durable(exchange.isDurable())
// .internal(exchange.isInternal())
.arguments(exchange.getArguments())
.autoDelete(exchange.isAutoDelete());
Map<String, Object> arguments = exchange.getArguments();
if (arguments != null) {
arguments.forEach(exchangeSpecification::argument);
}
if (exchange.isDelayed()) {
exchangeSpecification.argument("x-delayed-type", exchange.getType());
}
@@ -326,9 +322,9 @@ public class RabbitAmqpAdmin
.autoDelete(true)
.exclusive(true)
.classic()
// .durable(false)
.queue()
.declare();
return new Queue(queueInfo.name(), false, true, true);
}
catch (AmqpException ex) {
@@ -349,12 +345,10 @@ public class RabbitAmqpAdmin
management.queue(queue.getName())
.autoDelete(queue.isAutoDelete())
.exclusive(queue.isExclusive())
.arguments(queue.getArguments())
.classic()
// .durable(queue.isDurable())
.queue();
queue.getArguments().forEach(queueSpecification::argument);
try {
String actualName = queueSpecification.declare().name();
queue.setActualName(actualName);