forked from spring-projects/spring-amqp
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
spring-projectsGH-1473: Switch to CompletableFuture
Resolves spring-projects#1473 Given the stability of the project, it was simplest to copy the `AsyncRabbitTemplate` rather than adding a lot of conditional code. **2.4.x only; I will submit a separate PR for main**
- Loading branch information
1 parent
37109ad
commit 967f817
Showing
22 changed files
with
1,854 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
205 changes: 205 additions & 0 deletions
205
spring-amqp/src/main/java/org/springframework/amqp/core/AsyncAmqpTemplate2.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,205 @@ | ||
/* | ||
* Copyright 2020 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.concurrent.CompletableFuture; | ||
|
||
import org.springframework.core.ParameterizedTypeReference; | ||
|
||
/** | ||
* Classes implementing this interface can perform asynchronous send and | ||
* receive operations using {@link CompletableFuture}s. | ||
* | ||
* @author Gary Russell | ||
* @since 2.4.7 | ||
* | ||
*/ | ||
public interface AsyncAmqpTemplate2 { | ||
|
||
/** | ||
* Send a message to the default exchange with the default routing key. If the message | ||
* contains a correlationId property, it must be unique. | ||
* @param message the message. | ||
* @return the {@link CompletableFuture}. | ||
*/ | ||
CompletableFuture<Message> sendAndReceive(Message message); | ||
|
||
/** | ||
* Send a message to the default exchange with the supplied routing key. If the message | ||
* contains a correlationId property, it must be unique. | ||
* @param routingKey the routing key. | ||
* @param message the message. | ||
* @return the {@link CompletableFuture}. | ||
*/ | ||
CompletableFuture<Message> sendAndReceive(String routingKey, Message message); | ||
|
||
/** | ||
* Send a message to the supplied exchange and routing key. If the message | ||
* contains a correlationId property, it must be unique. | ||
* @param exchange the exchange. | ||
* @param routingKey the routing key. | ||
* @param message the message. | ||
* @return the {@link CompletableFuture}. | ||
*/ | ||
CompletableFuture<Message> sendAndReceive(String exchange, String routingKey, Message message); | ||
|
||
/** | ||
* Convert the object to a message and send it to the default exchange with the | ||
* default routing key. | ||
* @param object the object to convert. | ||
* @param <C> the expected result type. | ||
* @return the {@link CompletableFuture}. | ||
*/ | ||
<C> CompletableFuture<C> convertSendAndReceive(Object object); | ||
|
||
/** | ||
* Convert the object to a message and send it to the default exchange with the | ||
* provided routing key. | ||
* @param routingKey the routing key. | ||
* @param object the object to convert. | ||
* @param <C> the expected result type. | ||
* @return the {@link CompletableFuture}. | ||
*/ | ||
<C> CompletableFuture<C> convertSendAndReceive(String routingKey, Object object); | ||
|
||
/** | ||
* Convert the object to a message and send it to the provided exchange and | ||
* routing key. | ||
* @param exchange the exchange. | ||
* @param routingKey the routing key. | ||
* @param object the object to convert. | ||
* @param <C> the expected result type. | ||
* @return the {@link CompletableFuture}. | ||
*/ | ||
<C> CompletableFuture<C> convertSendAndReceive(String exchange, String routingKey, Object object); | ||
|
||
/** | ||
* Convert the object to a message and send it to the default exchange with the | ||
* default routing key after invoking the {@link MessagePostProcessor}. | ||
* If the post processor adds a correlationId property, it must be unique. | ||
* @param object the object to convert. | ||
* @param messagePostProcessor the post processor. | ||
* @param <C> the expected result type. | ||
* @return the {@link CompletableFuture}. | ||
*/ | ||
<C> CompletableFuture<C> convertSendAndReceive(Object object, MessagePostProcessor messagePostProcessor); | ||
|
||
/** | ||
* Convert the object to a message and send it to the default exchange with the | ||
* provided routing key after invoking the {@link MessagePostProcessor}. | ||
* If the post processor adds a correlationId property, it must be unique. | ||
* @param routingKey the routing key. | ||
* @param object the object to convert. | ||
* @param messagePostProcessor the post processor. | ||
* @param <C> the expected result type. | ||
* @return the {@link CompletableFuture}. | ||
*/ | ||
<C> CompletableFuture<C> convertSendAndReceive(String routingKey, Object object, | ||
MessagePostProcessor messagePostProcessor); | ||
|
||
/** | ||
* Convert the object to a message and send it to the provided exchange and | ||
* routing key after invoking the {@link MessagePostProcessor}. | ||
* If the post processor adds a correlationId property, it must be unique. | ||
* @param exchange the exchange | ||
* @param routingKey the routing key. | ||
* @param object the object to convert. | ||
* @param messagePostProcessor the post processor. | ||
* @param <C> the expected result type. | ||
* @return the {@link CompletableFuture}. | ||
*/ | ||
<C> CompletableFuture<C> convertSendAndReceive(String exchange, String routingKey, Object object, | ||
MessagePostProcessor messagePostProcessor); | ||
|
||
/** | ||
* Convert the object to a message and send it to the default exchange with the | ||
* default routing key. | ||
* @param object the object to convert. | ||
* @param responseType the response type. | ||
* @param <C> the expected result type. | ||
* @return the {@link CompletableFuture}. | ||
*/ | ||
<C> CompletableFuture<C> convertSendAndReceiveAsType(Object object, ParameterizedTypeReference<C> responseType); | ||
|
||
/** | ||
* Convert the object to a message and send it to the default exchange with the | ||
* provided routing key. | ||
* @param routingKey the routing key. | ||
* @param object the object to convert. | ||
* @param responseType the response type. | ||
* @param <C> the expected result type. | ||
* @return the {@link CompletableFuture}. | ||
*/ | ||
<C> CompletableFuture<C> convertSendAndReceiveAsType(String routingKey, Object object, | ||
ParameterizedTypeReference<C> responseType); | ||
|
||
/** | ||
* Convert the object to a message and send it to the provided exchange and | ||
* routing key. | ||
* @param exchange the exchange. | ||
* @param routingKey the routing key. | ||
* @param object the object to convert. | ||
* @param responseType the response type. | ||
* @param <C> the expected result type. | ||
* @return the {@link CompletableFuture}. | ||
*/ | ||
<C> CompletableFuture<C> convertSendAndReceiveAsType(String exchange, String routingKey, Object object, | ||
ParameterizedTypeReference<C> responseType); | ||
|
||
/** | ||
* Convert the object to a message and send it to the default exchange with the | ||
* default routing key after invoking the {@link MessagePostProcessor}. | ||
* If the post processor adds a correlationId property, it must be unique. | ||
* @param object the object to convert. | ||
* @param messagePostProcessor the post processor. | ||
* @param responseType the response type. | ||
* @param <C> the expected result type. | ||
* @return the {@link CompletableFuture}. | ||
*/ | ||
<C> CompletableFuture<C> convertSendAndReceiveAsType(Object object, MessagePostProcessor messagePostProcessor, | ||
ParameterizedTypeReference<C> responseType); | ||
|
||
/** | ||
* Convert the object to a message and send it to the default exchange with the | ||
* provided routing key after invoking the {@link MessagePostProcessor}. | ||
* If the post processor adds a correlationId property, it must be unique. | ||
* @param routingKey the routing key. | ||
* @param object the object to convert. | ||
* @param messagePostProcessor the post processor. | ||
* @param responseType the response type. | ||
* @param <C> the expected result type. | ||
* @return the {@link CompletableFuture}. | ||
*/ | ||
<C> CompletableFuture<C> convertSendAndReceiveAsType(String routingKey, Object object, | ||
MessagePostProcessor messagePostProcessor, ParameterizedTypeReference<C> responseType); | ||
|
||
/** | ||
* Convert the object to a message and send it to the provided exchange and | ||
* routing key after invoking the {@link MessagePostProcessor}. | ||
* If the post processor adds a correlationId property, it must be unique. | ||
* @param exchange the exchange | ||
* @param routingKey the routing key. | ||
* @param object the object to convert. | ||
* @param messagePostProcessor the post processor. | ||
* @param responseType the response type. | ||
* @param <C> the expected result type. | ||
* @return the {@link CompletableFuture}. | ||
*/ | ||
<C> CompletableFuture<C> convertSendAndReceiveAsType(String exchange, String routingKey, Object object, | ||
MessagePostProcessor messagePostProcessor, ParameterizedTypeReference<C> responseType); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.