From ecb5e113fd39df9d2097ab53d7b070c8f38f37ee Mon Sep 17 00:00:00 2001 From: Gary Russell Date: Wed, 10 Apr 2019 11:34:23 -0400 Subject: [PATCH] Remove deprecated classes and methods --- .../amqp/core/AmqpManagementOperations.java | 176 ----------- .../amqp/core/AnonymousQueue.java | 114 ------- ...bstractRabbitListenerContainerFactory.java | 9 +- .../config/ListenerContainerFactoryBean.java | 20 -- .../amqp/rabbit/config/NamespaceUtils.java | 32 -- .../amqp/rabbit/config/TemplateParser.java | 2 +- ...isherCallbackChannelConnectionFactory.java | 42 --- .../PublisherCallbackChannelImpl.java | 12 +- .../connection/RabbitResourceHolder.java | 18 -- .../amqp/rabbit/core/RabbitAdmin.java | 49 --- .../rabbit/core/RabbitManagementTemplate.java | 295 ------------------ .../amqp/rabbit/core/RabbitTemplate.java | 10 - .../AbstractMessageListenerContainer.java | 83 +---- ...DirectReplyToMessageListenerContainer.java | 15 - .../listener/MessageListenerContainer.java | 13 - .../MethodRabbitListenerEndpoint.java | 4 - .../AbstractAdaptableMessageListener.java | 11 - .../config/MessageListenerTestContainer.java | 7 - .../QueueParserPlaceholderTests-context.xml | 4 +- .../config/QueueParserTests-context.xml | 4 +- 20 files changed, 12 insertions(+), 908 deletions(-) delete mode 100644 spring-amqp/src/main/java/org/springframework/amqp/core/AmqpManagementOperations.java delete mode 100644 spring-rabbit/src/main/java/org/springframework/amqp/rabbit/connection/PublisherCallbackChannelConnectionFactory.java delete mode 100644 spring-rabbit/src/main/java/org/springframework/amqp/rabbit/core/RabbitManagementTemplate.java diff --git a/spring-amqp/src/main/java/org/springframework/amqp/core/AmqpManagementOperations.java b/spring-amqp/src/main/java/org/springframework/amqp/core/AmqpManagementOperations.java deleted file mode 100644 index 10ec8e76..00000000 --- a/spring-amqp/src/main/java/org/springframework/amqp/core/AmqpManagementOperations.java +++ /dev/null @@ -1,176 +0,0 @@ -/* - * Copyright 2015-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.amqp.core; - -import java.util.List; - -/** - * Interface specifying management operations. - * - * @author Gary Russell - * @since 1.5 - * - * @deprecated since 2.1 in favor of direct usage of target REST API client. - */ -@Deprecated -public interface AmqpManagementOperations { - - /** - * Add an exchange to the default vhost ('/'). - * @param exchange the exchange. - */ - void addExchange(Exchange exchange); - - /** - * Add an exchange to the specified vhost. - * @param vhost the vhost. - * @param exchange the exchange. - */ - void addExchange(String vhost, Exchange exchange); - - /** - * Purge a queue in the default vhost ('/'). - * @param queue the queue. - */ - void purgeQueue(Queue queue); - - /** - * Purge a queue in the provided vhost. - * @param vhost the vhost. - * @param queue the queue. - */ - void purgeQueue(String vhost, Queue queue); - - /** - * Delete a queue from the default vhost ('/'). - * @param queue the queue. - */ - void deleteQueue(Queue queue); - - /** - * Delete a queue from the provided vhost. - * @param vhost the vhost. - * @param queue the queue. - */ - void deleteQueue(String vhost, Queue queue); - - /** - * Get a specific queue from the default vhost ('/'). - * @param name the queue name. - * @return the Queue. - */ - Queue getQueue(String name); - - /** - * Get a specific queue from the provided vhost. - * @param vhost the vhost. - * @param name the queue name. - * @return the Queue. - */ - Queue getQueue(String vhost, String name); - - /** - * Get all queues. - * @return the queues. - */ - List getQueues(); - - /** - * Get all queues in the provided vhost. - * @param vhost the vhost. - * @return the queues. - */ - List getQueues(String vhost); - - /** - * Add a queue to the default vhost ('/'). - * @param queue the queue. - */ - void addQueue(Queue queue); - - /** - * Add a queue to the specified vhost. - * @param vhost the vhost. - * @param queue the queue. - */ - void addQueue(String vhost, Queue queue); - - /** - * Delete an exchange from the default vhost ('/'). - * @param exchange the queue. - */ - void deleteExchange(Exchange exchange); - - /** - * Delete an exchange from the provided vhost. - * @param vhost the vhost. - * @param exchange the queue. - */ - void deleteExchange(String vhost, Exchange exchange); - - /** - * Get a specific queue from the default vhost ('/'). - * @param name the exchange name. - * @return the Exchange. - */ - Exchange getExchange(String name); - - /** - * Get a specific exchange from the provided vhost. - * @param vhost the vhost. - * @param name the exchange name. - * @return the Exchange. - */ - Exchange getExchange(String vhost, String name); - - /** - * Get all exchanges. - * @return the exchanges. - */ - List getExchanges(); - - /** - * Get all exchanges in the provided vhost. Only {@link DirectExchange}, - * {@link FanoutExchange}, {@link HeadersExchange} and {@link TopicExchange}s - * are returned. - * @param vhost the vhost. - * @return the exchanges. - */ - List getExchanges(String vhost); - - /** - * Get all bindings. - * @return the bindings. - */ - List getBindings(); - - /** - * Get all bindings in the provided vhost. - * @param vhost the vhost. - * @return the bindings. - */ - List getBindings(String vhost); - - /** - * Get all bindings from the provided exchange in the provided vhost. - * @param vhost the vhost. - * @param exchange the exchange name. - * @return the bindings. - */ - List getBindingsForExchange(String vhost, String exchange); - -} diff --git a/spring-amqp/src/main/java/org/springframework/amqp/core/AnonymousQueue.java b/spring-amqp/src/main/java/org/springframework/amqp/core/AnonymousQueue.java index 1e513836..b501b871 100644 --- a/spring-amqp/src/main/java/org/springframework/amqp/core/AnonymousQueue.java +++ b/spring-amqp/src/main/java/org/springframework/amqp/core/AnonymousQueue.java @@ -16,12 +16,7 @@ package org.springframework.amqp.core; -import java.nio.ByteBuffer; import java.util.Map; -import java.util.UUID; - -import org.springframework.util.Assert; -import org.springframework.util.Base64Utils; /** * Represents an anonymous, non-durable, exclusive, auto-delete queue. The name has the @@ -50,32 +45,6 @@ public class AnonymousQueue extends Queue { this(org.springframework.amqp.core.Base64UrlNamingStrategy.DEFAULT, arguments); } - /** - * Construct a queue with a name provided by the supplied naming strategy. - * @param namingStrategy the naming strategy. - * @deprecated in favor of {@link #AnonymousQueue(NamingStrategy)}. - * - * @since 1.5.3 - */ - @Deprecated - public AnonymousQueue(NamingStrategy namingStrategy) { - this(namingStrategy, null); - } - - /** - * Construct a queue with a name provided by the supplied naming strategy with the - * supplied arguments. - * @param namingStrategy the naming strategy. - * @param arguments the arguments. - * @deprecated in favor of {@link #AnonymousQueue(NamingStrategy, Map)}. - * - * @since 1.5.3 - */ - @Deprecated - public AnonymousQueue(NamingStrategy namingStrategy, Map arguments) { - super(namingStrategy.generateName(), false, true, true, arguments); - } - /** * Construct a queue with a name provided by the supplied naming strategy. * @param namingStrategy the naming strategy. @@ -99,87 +68,4 @@ public class AnonymousQueue extends Queue { } } - /** - * A strategy to name anonymous queues. - * @deprecated - use the {@link org.springframework.amqp.core.NamingStrategy}. - * @since 1.5.3 - * - */ - @Deprecated - @FunctionalInterface - public interface NamingStrategy extends org.springframework.amqp.core.NamingStrategy { - - } - - /** - * Generates names with the form {@code } where - * 'prefix' is 'spring.gen-' by default - * (e.g. spring.gen-eIwaZAYgQv6LvwaDCfVTNQ); - * the 'base64url' String is generated from a UUID. The base64 alphabet - * is the "URL and Filename Safe Alphabet"; see RFC-4648. Trailing padding - * characters (@code =) are removed. - * @deprecated - use the {@link org.springframework.amqp.core.Base64UrlNamingStrategy}. - * @since 1.5.3 - */ - @Deprecated - public static class Base64UrlNamingStrategy implements NamingStrategy { - - /** - * The default instance - using {@code spring.gen-} as the prefix. - */ - public static final Base64UrlNamingStrategy DEFAULT = new Base64UrlNamingStrategy(); - - private final String prefix; - - /** - * Construct an instance using the default prefix {@code spring.gen-}. - */ - public Base64UrlNamingStrategy() { - this("spring.gen-"); - } - - /** - * Construct an instance using the supplied prefix. - * @param prefix The prefix. - */ - public Base64UrlNamingStrategy(String prefix) { - Assert.notNull(prefix, "'prefix' cannot be null; use an empty String "); - this.prefix = prefix; - } - - @Override - public String generateName() { - UUID uuid = UUID.randomUUID(); - ByteBuffer bb = ByteBuffer.wrap(new byte[16]); // NOSONAR - Magic # deprecated anyway - bb.putLong(uuid.getMostSignificantBits()) - .putLong(uuid.getLeastSignificantBits()); - // Convert to base64 and remove trailing = - return this.prefix + Base64Utils.encodeToUrlSafeString(bb.array()) - .replaceAll("=", ""); - } - - } - - /** - * Generates names using {@link UUID#randomUUID()}. - * (e.g. "f20c818a-006b-4416-bf91-643590fedb0e"). - * @author Gary Russell - * @deprecated - use the {@link org.springframework.amqp.core.UUIDNamingStrategy}. - * @since 2.0 - */ - @Deprecated - public static class UUIDNamingStrategy implements NamingStrategy { - - /** - * The default instance. - */ - public static final UUIDNamingStrategy DEFAULT = new UUIDNamingStrategy(); - - @Override - public String generateName() { - return UUID.randomUUID().toString(); - } - - } - } diff --git a/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/config/AbstractRabbitListenerContainerFactory.java b/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/config/AbstractRabbitListenerContainerFactory.java index 889a75ee..6d81d05e 100644 --- a/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/config/AbstractRabbitListenerContainerFactory.java +++ b/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/config/AbstractRabbitListenerContainerFactory.java @@ -137,7 +137,7 @@ public abstract class AbstractRabbitListenerContainerFactory childElements = DomUtils.getChildElementsByTagName(element, "bean"); - BeanComponentDefinition innerComponentDefinition = null; - if (childElements != null && childElements.size() == 1) { - Element beanElement = childElements.get(0); - BeanDefinitionParserDelegate delegate = parserContext.getDelegate(); - BeanDefinitionHolder bdHolder = delegate.parseBeanDefinitionElement(beanElement); - bdHolder = delegate.decorateBeanDefinitionIfRequired(beanElement, bdHolder); // NOSONAR not used - BeanDefinition inDef = bdHolder.getBeanDefinition(); - String beanName = BeanDefinitionReaderUtils.generateBeanName(inDef, parserContext.getRegistry()); - innerComponentDefinition = new BeanComponentDefinition(inDef, beanName); - parserContext.registerBeanComponent(innerComponentDefinition); - } - - String ref = element.getAttribute(REF_ATTRIBUTE); - Assert.isTrue(!StringUtils.hasText(ref) || innerComponentDefinition == null, //NOSONAR - "Ambiguous definition. Inner bean " - + (innerComponentDefinition == null ? innerComponentDefinition : innerComponentDefinition - .getBeanDefinition().getBeanClassName()) + " declaration and \"ref\" " + ref - + " are not allowed together."); - return innerComponentDefinition; - } - /** * Parses 'auto-declare' and 'declared-by' attributes. * diff --git a/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/config/TemplateParser.java b/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/config/TemplateParser.java index cc4e54c4..8dea913b 100644 --- a/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/config/TemplateParser.java +++ b/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/config/TemplateParser.java @@ -107,7 +107,7 @@ class TemplateParser extends AbstractSingleBeanDefinitionParser { } NamespaceUtils.setValueIfAttributeDefined(builder, element, CHANNEL_TRANSACTED_ATTRIBUTE); - NamespaceUtils.setValueIfAttributeDefined(builder, element, QUEUE_ATTRIBUTE); + NamespaceUtils.setValueIfAttributeDefined(builder, element, QUEUE_ATTRIBUTE, "defaultReceiveQueue"); NamespaceUtils.setValueIfAttributeDefined(builder, element, EXCHANGE_ATTRIBUTE); NamespaceUtils.setValueIfAttributeDefined(builder, element, ROUTING_KEY_ATTRIBUTE); NamespaceUtils.setValueIfAttributeDefined(builder, element, RECEIVE_TIMEOUT_ATTRIBUTE); diff --git a/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/connection/PublisherCallbackChannelConnectionFactory.java b/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/connection/PublisherCallbackChannelConnectionFactory.java deleted file mode 100644 index caed38f8..00000000 --- a/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/connection/PublisherCallbackChannelConnectionFactory.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2015-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.amqp.rabbit.connection; - -/** - * Connection factories implementing this interface return a connection that - * provides {@code PublisherCallbackChannel} channel instances when confirms - * or returns are enabled. - * @deprecated in favor of default methods on ConnectionFactory. - * - * @author Gary Russell - * @since 1.5 - * - */ -@Deprecated -public interface PublisherCallbackChannelConnectionFactory { - - /** - * @return true if publisher confirms are enabled. - */ - boolean isPublisherConfirms(); - - /** - * @return true if publisher returns are enabled. - */ - boolean isPublisherReturns(); - -} diff --git a/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/connection/PublisherCallbackChannelImpl.java b/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/connection/PublisherCallbackChannelImpl.java index c537c636..ca57b9be 100644 --- a/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/connection/PublisherCallbackChannelImpl.java +++ b/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/connection/PublisherCallbackChannelImpl.java @@ -113,16 +113,10 @@ public class PublisherCallbackChannelImpl /** * Create a {@link PublisherCallbackChannelImpl} instance based on the provided - * delegate. - * @param delegate the {@link Channel} to delegate. - * @deprecated since 2.2.1 in favor of - * {@link #PublisherCallbackChannelImpl(Channel, ExecutorService)} + * delegate and executor. + * @param delegate the delegate channel. + * @param executor the exceutor. */ - @Deprecated - public PublisherCallbackChannelImpl(Channel delegate) { - this(delegate, null); // NOSONAR = deprecated ctor - } - public PublisherCallbackChannelImpl(Channel delegate, ExecutorService executor) { Assert.notNull(executor, "'executor' must not be null"); this.delegate = delegate; diff --git a/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/connection/RabbitResourceHolder.java b/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/connection/RabbitResourceHolder.java index 14a20b89..7690eb8c 100644 --- a/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/connection/RabbitResourceHolder.java +++ b/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/connection/RabbitResourceHolder.java @@ -30,7 +30,6 @@ import org.springframework.amqp.AmqpIOException; import org.springframework.lang.Nullable; import org.springframework.transaction.support.ResourceHolderSupport; import org.springframework.util.Assert; -import org.springframework.util.CollectionUtils; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; @@ -83,11 +82,6 @@ public class RabbitResourceHolder extends ResourceHolderSupport { this.releaseAfterCompletion = releaseAfterCompletion; } - @Deprecated - public final boolean isFrozen() { - return false; - } - /** * Whether the resources should be released after transaction completion. * Default true. Listener containers set to false because the listener continues @@ -143,18 +137,6 @@ public class RabbitResourceHolder extends ResourceHolderSupport { return (!this.connections.isEmpty() ? this.connections.get(0) : null); } - /** - * Find a single connection of this type. - * @param connectionType the type. - * @return the connection or null. - * @deprecated Not used. - */ - @Deprecated - @Nullable - public Connection getConnection(Class connectionType) { - return CollectionUtils.findValueOfType(this.connections, connectionType); - } - @Nullable public Channel getChannel() { return (!this.channels.isEmpty() ? this.channels.get(0) : null); diff --git a/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/core/RabbitAdmin.java b/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/core/RabbitAdmin.java index 334ceaec..b03c82e4 100644 --- a/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/core/RabbitAdmin.java +++ b/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/core/RabbitAdmin.java @@ -19,7 +19,6 @@ package org.springframework.amqp.rabbit.core; import java.io.IOException; import java.util.ArrayList; import java.util.Collection; -import java.util.Collections; import java.util.HashMap; import java.util.LinkedList; import java.util.List; @@ -137,8 +136,6 @@ public class RabbitAdmin implements AmqpAdmin, ApplicationContextAware, Applicat private ApplicationEventPublisher applicationEventPublisher; - private boolean declareCollections = false; - private TaskExecutor taskExecutor = new SimpleAsyncTaskExecutor(); private volatile boolean running = false; @@ -188,20 +185,6 @@ public class RabbitAdmin implements AmqpAdmin, ApplicationContextAware, Applicat this.ignoreDeclarationExceptions = ignoreDeclarationExceptions; } - /** - * Set to false to disable declaring collections of {@link Declarable}. - * Since the admin has to iterate over all Collection beans, this may - * cause undesirable side-effects in some cases. Default true. - * @param declareCollections set to false to prevent declarations of collections. - * @since 1.7.7 - * @deprecated - users should use {@link Declarables} beans instead of collections of - * {@link Declarable}. - */ - @Deprecated - public void setDeclareCollections(boolean declareCollections) { - this.declareCollections = declareCollections; - } - /** * @return the last {@link DeclarationExceptionEvent} that was detected in this admin. * @@ -570,7 +553,6 @@ public class RabbitAdmin implements AmqpAdmin, ApplicationContextAware, Applicat Collection contextBindings = new LinkedList( this.applicationContext.getBeansOfType(Binding.class).values()); - processLegacyCollections(contextExchanges, contextQueues, contextBindings); processDeclarables(contextExchanges, contextQueues, contextBindings); final Collection exchanges = filterDeclarables(contextExchanges); @@ -612,37 +594,6 @@ public class RabbitAdmin implements AmqpAdmin, ApplicationContextAware, Applicat } - // TODO: remove in 3.0 - private void processLegacyCollections(Collection contextExchanges, // NOSONAR complexity - Collection contextQueues, Collection contextBindings) { - - @SuppressWarnings("rawtypes") - Collection collections = this.declareCollections - ? this.applicationContext.getBeansOfType(Collection.class, false, false).values() - : Collections.emptyList(); - boolean shouldWarn = false; - for (Collection collection : collections) { - if (collection.size() > 0 && collection.iterator().next() instanceof Declarable) { - shouldWarn = true; - for (Object declarable : collection) { - if (declarable instanceof Exchange) { - contextExchanges.add((Exchange) declarable); - } - else if (declarable instanceof Queue) { - contextQueues.add((Queue) declarable); - } - else if (declarable instanceof Binding) { - contextBindings.add((Binding) declarable); - } - } - } - } - if (shouldWarn && this.logger.isWarnEnabled()) { - this.logger.warn("Beans of type Collection are discouraged, and deprecated, " - + "use Declarables beans instead"); - } - } - private void processDeclarables(Collection contextExchanges, Collection contextQueues, Collection contextBindings) { Collection declarables = this.applicationContext.getBeansOfType(Declarables.class, false, true) diff --git a/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/core/RabbitManagementTemplate.java b/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/core/RabbitManagementTemplate.java deleted file mode 100644 index e5f7057a..00000000 --- a/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/core/RabbitManagementTemplate.java +++ /dev/null @@ -1,295 +0,0 @@ -/* - * Copyright 2015-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.amqp.rabbit.core; - -import java.util.List; -import java.util.stream.Collectors; - -import org.springframework.amqp.AmqpException; -import org.springframework.amqp.core.AbstractExchange; -import org.springframework.amqp.core.Binding; -import org.springframework.amqp.core.Binding.DestinationType; -import org.springframework.amqp.core.DirectExchange; -import org.springframework.amqp.core.Exchange; -import org.springframework.amqp.core.FanoutExchange; -import org.springframework.amqp.core.HeadersExchange; -import org.springframework.amqp.core.Queue; -import org.springframework.amqp.core.TopicExchange; -import org.springframework.lang.Nullable; - -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; - -/** - * A convenience wrapper for the RabbitMQ {@link Client} providing convenient access to - * the REST methods using the familiar Spring AMQP domain objects for {@link Queue}, - * {@link Exchange} and {@link Binding}. For more complete access, including access to - * properties not available in the Spring AMQP domain classes, use the {@link Client} - * directly. - * - * @author Gary Russell - * @author Artem Bilan - * - * @since 1.5 - * - * @deprecated since 2.1 in favor of direct {@link Client} usage. - */ -@Deprecated -public class RabbitManagementTemplate implements org.springframework.amqp.core.AmqpManagementOperations { - - private static final String DEFAULT_VHOST = "/"; - - private final Client rabbitClient; - - - /** - * Construct a template using uri "localhost:15672/api/" and user guest/guest. - */ - public RabbitManagementTemplate() { - this("http://localhost:15672/api/", "guest", "guest"); - } - - /** - * Construct a template using the supplied client. - * @param rabbitClient the client. - */ - public RabbitManagementTemplate(Client rabbitClient) { - this.rabbitClient = rabbitClient; - } - - /** - * Construct a template using the supplied uri. - * @param uri the uri - must include user info, e.g. - * "http://guest:guest@localhost:15672/api/". - * @since 2.0 - */ - public RabbitManagementTemplate(String uri) { - try { - this.rabbitClient = new Client(uri); - } - catch (Exception e) { - throw new AmqpException(e); - } - } - - /** - * Construct a template using the supplied uri. - * @param uri the uri. - * @param username the user. - * @param password the password. - */ - public RabbitManagementTemplate(String uri, String username, String password) { - try { - this.rabbitClient = new Client(uri, username, password); - } - catch (Exception e) { - throw new AmqpException(e); - } - } - - /** - * @return the rabbitClient - */ - public Client getClient() { - return this.rabbitClient; - } - - @Override - public void addExchange(Exchange exchange) { - addExchange(DEFAULT_VHOST, exchange); - } - - @Override - public void addExchange(String vhost, Exchange exchange) { - ExchangeInfo info = new ExchangeInfo(); - info.setArguments(exchange.getArguments()); - info.setAutoDelete(exchange.isAutoDelete()); - info.setDurable(exchange.isDurable()); - info.setType(exchange.getType()); - this.rabbitClient.declareExchange(vhost, exchange.getName(), info); - } - - @Override - public void purgeQueue(Queue queue) { - this.rabbitClient.purgeQueue(DEFAULT_VHOST, queue.getName()); - } - - @Override - public void purgeQueue(String vhost, Queue queue) { - this.rabbitClient.purgeQueue(vhost, queue.getName()); - } - - @Override - public void deleteQueue(Queue queue) { - this.rabbitClient.deleteQueue(DEFAULT_VHOST, queue.getName()); - } - - @Override - public void deleteQueue(String vhost, Queue queue) { - this.rabbitClient.deleteQueue(vhost, queue.getName()); - } - - @Override - public Queue getQueue(String name) { - return getQueue(DEFAULT_VHOST, name); - } - - @Override - public Queue getQueue(String vhost, String name) { - return convert(this.rabbitClient.getQueue(vhost, name)); - } - - @Override - public List getQueues() { - return convertQueueList(this.rabbitClient.getQueues()); - } - - @Override - public List getQueues(String vhost) { - return convertQueueList(this.rabbitClient.getQueues(vhost)); - } - - @Override - public void addQueue(Queue queue) { - addQueue(DEFAULT_VHOST, queue); - } - - @Override - public void addQueue(String vhost, Queue queue) { - QueueInfo info = new QueueInfo(); - info.setArguments(queue.getArguments()); - info.setAutoDelete(queue.isAutoDelete()); - info.setDurable(queue.isDurable()); - info.setExclusive(queue.isExclusive()); - this.rabbitClient.declareQueue(vhost, queue.getName(), info); - } - - @Override - public void deleteExchange(Exchange exchange) { - deleteExchange(DEFAULT_VHOST, exchange); - } - - @Override - public void deleteExchange(String vhost, Exchange exchange) { - this.rabbitClient.deleteExchange(vhost, exchange.getName()); - } - - @Override - public Exchange getExchange(String name) { - return getExchange(DEFAULT_VHOST, name); - } - - @Override - public Exchange getExchange(String vhost, String name) { - return convert(this.rabbitClient.getExchange(vhost, name)); - } - - @Override - public List getExchanges() { - return convertExchangeList(this.rabbitClient.getExchanges()); - } - - @Override - public List getExchanges(String vhost) { - return convertExchangeList(this.rabbitClient.getExchanges(vhost)); - } - - @Override - public List getBindings() { - return convertBindingList(this.rabbitClient.getBindings()); - } - - @Override - public List getBindings(String vhost) { - return convertBindingList(this.rabbitClient.getBindings(vhost)); - } - - @Override - public List getBindingsForExchange(String vhost, String exchange) { - return convertBindingList(this.rabbitClient.getBindingsBySource(vhost, exchange)); - } - - private List convertQueueList(List queues) { - return queues.stream() - .map(this::convert) - .collect(Collectors.toList()); - } - - @Nullable - private Queue convert(@Nullable QueueInfo qi) { - if (qi == null) { - return null; - } - return new Queue(qi.getName(), qi.isDurable(), qi.isExclusive(), qi.isAutoDelete(), - qi.getArguments()); - } - - private List convertExchangeList(List exchanges) { - return exchanges.stream() - .map(this::convert) - .collect(Collectors.toList()); - } - - @Nullable - private Exchange convert(@Nullable ExchangeInfo ei) { - if (ei == null) { - return null; - } - boolean delayed = false; - if (ei.getType().equals("x-delayed-message")) { - ei.setType((String) ei.getArguments().get("x-delayed-type")); - delayed = true; - } - AbstractExchange exchange; - if (ei.getType().equals("direct")) { - exchange = new DirectExchange(ei.getName(), ei.isDurable(), ei.isAutoDelete(), ei.getArguments()); - } - else if (ei.getType().equals("fanout")) { - exchange = new FanoutExchange(ei.getName(), ei.isDurable(), ei.isAutoDelete(), ei.getArguments()); - } - else if (ei.getType().equals("headers")) { - exchange = new HeadersExchange(ei.getName(), ei.isDurable(), ei.isAutoDelete(), ei.getArguments()); - } - else if (ei.getType().equals("topic")) { - exchange = new TopicExchange(ei.getName(), ei.isDurable(), ei.isAutoDelete(), ei.getArguments()); - } - else { - return null; - } - exchange.setDelayed(delayed); - exchange.setInternal(ei.isInternal()); - return exchange; - } - - private List convertBindingList(List bindings) { - return bindings.stream() - .map(this::convert) - .collect(Collectors.toList()); - } - - @Nullable - private Binding convert(@Nullable BindingInfo bi) { - if (bi == null) { - return null; - } - return new Binding(bi.getDestination(), DestinationType.valueOf(bi.getDestinationType().toUpperCase()), - bi.getSource(), bi.getRoutingKey(), bi.getArguments()); - } - -} diff --git a/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/core/RabbitTemplate.java b/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/core/RabbitTemplate.java index 92e329f9..71c027c1 100644 --- a/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/core/RabbitTemplate.java +++ b/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/core/RabbitTemplate.java @@ -323,16 +323,6 @@ public class RabbitTemplate extends RabbitAccessor // NOSONAR type line count return this.routingKey; } - /** - * The name of the default queue to receive messages from when none is specified explicitly. - * @param queue the default queue name to use for receive - * @deprecated in favor of {@link #setDefaultReceiveQueue(String)}. - */ - @Deprecated - public void setQueue(String queue) { - this.defaultReceiveQueue = queue; - } - /** * The name of the default queue to receive messages from when none is specified explicitly. * @param queue the default queue name to use for receive diff --git a/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/listener/AbstractMessageListenerContainer.java b/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/listener/AbstractMessageListenerContainer.java index c2a21a3a..d01e82c4 100644 --- a/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/listener/AbstractMessageListenerContainer.java +++ b/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/listener/AbstractMessageListenerContainer.java @@ -398,24 +398,6 @@ public abstract class AbstractMessageListenerContainer extends RabbitAccessor this.exposeListenerChannel = exposeListenerChannel; } - /** - * Set the message listener implementation to register. This can be either a Spring - * {@link MessageListener} object or a Spring {@link ChannelAwareMessageListener} - * object. - * - * @param messageListener The listener. - * @throws IllegalArgumentException if the supplied listener is not a - * {@link MessageListener} or a {@link ChannelAwareMessageListener} - * @deprecated use {@link #setMessageListener(MessageListener)}. - * @see MessageListener - * @see ChannelAwareMessageListener - */ - @Deprecated - public void setMessageListener(Object messageListener) { - checkMessageListener(messageListener); - setMessageListener((MessageListener) messageListener); - } - /** * Set the {@link MessageListener}. * @param messageListener the listener. @@ -425,28 +407,16 @@ public abstract class AbstractMessageListenerContainer extends RabbitAccessor this.messageListener = messageListener; } - /** - * Set the {@link ChannelAwareMessageListener}. - * @param messageListener the listener. - * @since 2.0 - * @deprecated use {@link #setMessageListener(MessageListener)} since - * {@link ChannelAwareMessageListener} now inherits {@link MessageListener}. - */ - @Deprecated - public void setChannelAwareMessageListener(ChannelAwareMessageListener messageListener) { - this.messageListener = messageListener; - } - /** * Check the given message listener, throwing an exception if it does not correspond to a supported listener type. *

* Only a Spring {@link MessageListener} object will be accepted. - * @param messageListener the message listener object to check + * @param listener the message listener object to check * @throws IllegalArgumentException if the supplied listener is not a MessageListener * @see MessageListener */ - protected void checkMessageListener(Object messageListener) { - if (!(messageListener instanceof MessageListener)) { + protected void checkMessageListener(Object listener) { + if (!(listener instanceof MessageListener)) { throw new IllegalArgumentException("Message listener needs to be of type [" + MessageListener.class.getName() + "] or [" + ChannelAwareMessageListener.class.getName() + "]"); } @@ -469,28 +439,6 @@ public abstract class AbstractMessageListenerContainer extends RabbitAccessor this.errorHandler = errorHandler; } - /** - * Set the {@link MessageConverter} strategy for converting AMQP Messages. - * @param messageConverter the message converter to use - * @deprecated - this converter is not used by the container; it was only - * used to configure the converter for a {@code @RabbitListener} adapter. - * That is now handled differently. If you are manually creating a listener - * container, the converter must be configured in a listener adapter (if - * present). - */ - @Deprecated - public void setMessageConverter(MessageConverter messageConverter) { - this.logger.warn("It is preferred to configure the message converter via the endpoint. " - + "See RabbitListenerEndpoint.setMessageConverter"); - this.messageConverter = messageConverter; - } - - @Override - @Deprecated - public MessageConverter getMessageConverter() { - return this.messageConverter; - } - /** * Determine whether or not the container should de-batch batched * messages (true) or call the listener with the batch (false). Default: true. @@ -938,17 +886,6 @@ public abstract class AbstractMessageListenerContainer extends RabbitAccessor return this.messagePropertiesConverter; } - /** - * Return the admin. - * @return the admin. - * @deprecated in favor of {@link #getAmqpAdmin()} - */ - @Deprecated - @Nullable - protected AmqpAdmin getRabbitAdmin() { - return getAmqpAdmin(); - } - @Nullable protected AmqpAdmin getAmqpAdmin() { return this.amqpAdmin; @@ -967,20 +904,6 @@ public abstract class AbstractMessageListenerContainer extends RabbitAccessor this.amqpAdmin = amqpAdmin; } - /** - * Set the {@link AmqpAdmin}, used to declare any auto-delete queues, bindings - * etc when the container is started. Only needed if those queues use conditional - * declaration (have a 'declared-by' attribute). If not specified, an internal - * admin will be used which will attempt to declare all elements not having a - * 'declared-by' attribute. - * @param amqpAdmin The admin. - * @deprecated in favor of {@link #setAmqpAdmin(AmqpAdmin)} - */ - @Deprecated - public final void setRabbitAdmin(AmqpAdmin amqpAdmin) { - setAmqpAdmin(amqpAdmin); - } - /** * If all of the configured queue(s) are not available on the broker, this setting * determines whether the condition is fatal. When true, and diff --git a/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/listener/DirectReplyToMessageListenerContainer.java b/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/listener/DirectReplyToMessageListenerContainer.java index 78a12ccc..7819f4d2 100644 --- a/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/listener/DirectReplyToMessageListenerContainer.java +++ b/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/listener/DirectReplyToMessageListenerContainer.java @@ -82,21 +82,6 @@ public class DirectReplyToMessageListenerContainer extends DirectMessageListener throw new UnsupportedOperationException(); } - @Override - @SuppressWarnings("deprecation") - @Deprecated - public void setMessageListener(Object messageListener) { - throw new UnsupportedOperationException( - "'messageListener' must be a 'MessageListener' or 'ChannelAwareMessageListener'"); - } - - @Override - @SuppressWarnings("deprecation") - @Deprecated - public void setChannelAwareMessageListener(ChannelAwareMessageListener messageListener) { - setMessageListener(messageListener); - } - @Override public void setMessageListener(MessageListener messageListener) { if (messageListener instanceof ChannelAwareMessageListener) { diff --git a/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/listener/MessageListenerContainer.java b/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/listener/MessageListenerContainer.java index feb38ae2..ed9620a4 100644 --- a/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/listener/MessageListenerContainer.java +++ b/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/listener/MessageListenerContainer.java @@ -17,7 +17,6 @@ package org.springframework.amqp.rabbit.listener; import org.springframework.amqp.core.MessageListener; -import org.springframework.amqp.support.converter.MessageConverter; import org.springframework.context.SmartLifecycle; /** @@ -37,18 +36,6 @@ public interface MessageListenerContainer extends SmartLifecycle { */ void setupMessageListener(MessageListener messageListener); - /** - * @return the {@link MessageConverter} that can be used to - * convert {@link org.springframework.amqp.core.Message}, if any. - * @deprecated - this converter is not used by the container; it was only - * used to configure the converter for a {@code @RabbitListener} adapter. - * That is now handled differently. If you are manually creating a listener - * container, the converter must be configured in a listener adapter (if - * present). - */ - @Deprecated - MessageConverter getMessageConverter(); - /** * Do not check for missing or mismatched queues during startup. Used for lazily * loaded message listener containers to avoid a deadlock when starting such diff --git a/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/listener/MethodRabbitListenerEndpoint.java b/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/listener/MethodRabbitListenerEndpoint.java index 5b9865f4..ed8e4257 100644 --- a/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/listener/MethodRabbitListenerEndpoint.java +++ b/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/listener/MethodRabbitListenerEndpoint.java @@ -125,10 +125,6 @@ public class MethodRabbitListenerEndpoint extends AbstractRabbitListenerEndpoint messageListener.setResponseAddress(replyToAddress); } MessageConverter messageConverter = getMessageConverter(); - if (messageConverter == null) { - // fall back to the legacy converter holder in the container - messageConverter = container.getMessageConverter(); - } if (messageConverter != null) { messageListener.setMessageConverter(messageConverter); } diff --git a/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/listener/adapter/AbstractAdaptableMessageListener.java b/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/listener/adapter/AbstractAdaptableMessageListener.java index 7f6c74d9..628cb53b 100644 --- a/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/listener/adapter/AbstractAdaptableMessageListener.java +++ b/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/listener/adapter/AbstractAdaptableMessageListener.java @@ -194,17 +194,6 @@ public abstract class AbstractAdaptableMessageListener implements ChannelAwareMe this.messageConverter = messageConverter; } - /** - * Set a post processor to process the reply immediately before - * {@code Channel#basicPublish()}. Often used to compress the data. - * @param replyPostProcessor the reply post processor. - * @deprecated in favor of {@link #setBeforeSendReplyPostProcessors(MessagePostProcessor...)}. - */ - @Deprecated - public void setReplyPostProcessor(MessagePostProcessor replyPostProcessor) { - setBeforeSendReplyPostProcessors(replyPostProcessor); - } - /** * Set post processors that will be applied before sending replies. * @param beforeSendReplyPostProcessors the post processors. diff --git a/spring-rabbit/src/test/java/org/springframework/amqp/rabbit/config/MessageListenerTestContainer.java b/spring-rabbit/src/test/java/org/springframework/amqp/rabbit/config/MessageListenerTestContainer.java index 6742eb97..b42baf5d 100644 --- a/spring-rabbit/src/test/java/org/springframework/amqp/rabbit/config/MessageListenerTestContainer.java +++ b/spring-rabbit/src/test/java/org/springframework/amqp/rabbit/config/MessageListenerTestContainer.java @@ -19,7 +19,6 @@ package org.springframework.amqp.rabbit.config; import org.springframework.amqp.core.MessageListener; import org.springframework.amqp.rabbit.listener.MessageListenerContainer; import org.springframework.amqp.rabbit.listener.RabbitListenerEndpoint; -import org.springframework.amqp.support.converter.MessageConverter; import org.springframework.beans.factory.DisposableBean; import org.springframework.beans.factory.InitializingBean; @@ -100,12 +99,6 @@ public class MessageListenerTestContainer public void setupMessageListener(MessageListener messageListener) { } - @Override - @Deprecated - public MessageConverter getMessageConverter() { - return null; - } - @Override public void afterPropertiesSet() { initializationInvoked = true; diff --git a/spring-rabbit/src/test/resources/org/springframework/amqp/rabbit/config/QueueParserPlaceholderTests-context.xml b/spring-rabbit/src/test/resources/org/springframework/amqp/rabbit/config/QueueParserPlaceholderTests-context.xml index 872b5b63..f90c9553 100644 --- a/spring-rabbit/src/test/resources/org/springframework/amqp/rabbit/config/QueueParserPlaceholderTests-context.xml +++ b/spring-rabbit/src/test/resources/org/springframework/amqp/rabbit/config/QueueParserPlaceholderTests-context.xml @@ -34,9 +34,9 @@ - + - + diff --git a/spring-rabbit/src/test/resources/org/springframework/amqp/rabbit/config/QueueParserTests-context.xml b/spring-rabbit/src/test/resources/org/springframework/amqp/rabbit/config/QueueParserTests-context.xml index 4ece9d8e..676c05ef 100644 --- a/spring-rabbit/src/test/resources/org/springframework/amqp/rabbit/config/QueueParserTests-context.xml +++ b/spring-rabbit/src/test/resources/org/springframework/amqp/rabbit/config/QueueParserTests-context.xml @@ -22,9 +22,9 @@ - + - +