AMQP-806: Move new invoke() to RabbitOperations
JIRA: https://jira.spring.io/browse/AMQP-806 * Use `default` in the in the `RabbitOperations` whenever it is possible for delegations instead of on the `RabbitTemplate` level
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -26,9 +26,11 @@ import org.springframework.core.ParameterizedTypeReference;
|
||||
|
||||
/**
|
||||
* Rabbit specific methods for Amqp functionality.
|
||||
*
|
||||
* @author Mark Pollack
|
||||
* @author Mark Fisher
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public interface RabbitOperations extends AmqpTemplate {
|
||||
|
||||
@@ -52,7 +54,22 @@ public interface RabbitOperations extends AmqpTemplate {
|
||||
* @throws AmqpException if one occurs.
|
||||
* @since 2.0
|
||||
*/
|
||||
<T> T invoke(OperationsCallback<T> action) throws AmqpException;
|
||||
default <T> T invoke(OperationsCallback<T> action) throws AmqpException {
|
||||
return invoke(action, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoke operations on the same channel.
|
||||
* If callbacks are needed, both callbacks must be supplied.
|
||||
* @param action the callback.
|
||||
* @param acks a confirm callback for acks.
|
||||
* @param nacks a confirm callback for nacks.
|
||||
* @param <T> the return type.
|
||||
* @return the result of the action method.
|
||||
* @since 2.1
|
||||
*/
|
||||
<T> T invoke(OperationsCallback<T> action, com.rabbitmq.client.ConfirmCallback acks,
|
||||
com.rabbitmq.client.ConfirmCallback nacks);
|
||||
|
||||
/**
|
||||
* Delegate to the underlying dedicated channel to wait for confirms. The connection
|
||||
@@ -318,8 +335,10 @@ public interface RabbitOperations extends AmqpTemplate {
|
||||
* @return the response if there is one
|
||||
* @throws AmqpException if there is a problem
|
||||
*/
|
||||
<T> T convertSendAndReceiveAsType(String exchange, String routingKey, Object message,
|
||||
CorrelationData correlationData, ParameterizedTypeReference<T> responseType) throws AmqpException;
|
||||
default <T> T convertSendAndReceiveAsType(String exchange, String routingKey, Object message,
|
||||
CorrelationData correlationData, ParameterizedTypeReference<T> responseType) throws AmqpException {
|
||||
return convertSendAndReceiveAsType(exchange, routingKey, message, null, correlationData, responseType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Basic RPC pattern with conversion. Send a Java object converted to a message to a
|
||||
|
||||
@@ -1426,12 +1426,6 @@ public class RabbitTemplate extends RabbitAccessor implements BeanFactoryAware,
|
||||
return convertSendAndReceiveAsType(exchange, routingKey, message, (CorrelationData) null, responseType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T convertSendAndReceiveAsType(final String exchange, final String routingKey, final Object message,
|
||||
CorrelationData correlationData, ParameterizedTypeReference<T> responseType) throws AmqpException {
|
||||
return convertSendAndReceiveAsType(exchange, routingKey, message, null, correlationData, responseType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T convertSendAndReceiveAsType(final Object message, final MessagePostProcessor messagePostProcessor,
|
||||
ParameterizedTypeReference<T> responseType) throws AmqpException {
|
||||
@@ -1848,20 +1842,6 @@ public class RabbitTemplate extends RabbitAccessor implements BeanFactoryAware,
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T invoke(OperationsCallback<T> action) {
|
||||
return invoke(action, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoke operations on the same channel.
|
||||
* If callbacks are needed, both callbacks must be supplied.
|
||||
* @param action the callback.
|
||||
* @param acks a confirm callback for acks.
|
||||
* @param nacks a confirm callback for nacks.
|
||||
* @param <T> the return type.
|
||||
* @return the result of the action method.
|
||||
* @since 2.1
|
||||
*/
|
||||
public <T> T invoke(OperationsCallback<T> action, com.rabbitmq.client.ConfirmCallback acks,
|
||||
com.rabbitmq.client.ConfirmCallback nacks) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user