|
| 1 | +/* |
| 2 | + * Copyright 2020 the original author or authors. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * https://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +package org.springframework.amqp.core; |
| 18 | + |
| 19 | +import java.util.concurrent.CompletableFuture; |
| 20 | + |
| 21 | +import org.springframework.core.ParameterizedTypeReference; |
| 22 | + |
| 23 | +/** |
| 24 | + * Classes implementing this interface can perform asynchronous send and |
| 25 | + * receive operations using {@link CompletableFuture}s. |
| 26 | + * |
| 27 | + * @author Gary Russell |
| 28 | + * @since 2.4.7 |
| 29 | + * |
| 30 | + */ |
| 31 | +public interface AsyncAmqpTemplate2 { |
| 32 | + |
| 33 | + /** |
| 34 | + * Send a message to the default exchange with the default routing key. If the message |
| 35 | + * contains a correlationId property, it must be unique. |
| 36 | + * @param message the message. |
| 37 | + * @return the {@link CompletableFuture}. |
| 38 | + */ |
| 39 | + CompletableFuture<Message> sendAndReceive(Message message); |
| 40 | + |
| 41 | + /** |
| 42 | + * Send a message to the default exchange with the supplied routing key. If the message |
| 43 | + * contains a correlationId property, it must be unique. |
| 44 | + * @param routingKey the routing key. |
| 45 | + * @param message the message. |
| 46 | + * @return the {@link CompletableFuture}. |
| 47 | + */ |
| 48 | + CompletableFuture<Message> sendAndReceive(String routingKey, Message message); |
| 49 | + |
| 50 | + /** |
| 51 | + * Send a message to the supplied exchange and routing key. If the message |
| 52 | + * contains a correlationId property, it must be unique. |
| 53 | + * @param exchange the exchange. |
| 54 | + * @param routingKey the routing key. |
| 55 | + * @param message the message. |
| 56 | + * @return the {@link CompletableFuture}. |
| 57 | + */ |
| 58 | + CompletableFuture<Message> sendAndReceive(String exchange, String routingKey, Message message); |
| 59 | + |
| 60 | + /** |
| 61 | + * Convert the object to a message and send it to the default exchange with the |
| 62 | + * default routing key. |
| 63 | + * @param object the object to convert. |
| 64 | + * @param <C> the expected result type. |
| 65 | + * @return the {@link CompletableFuture}. |
| 66 | + */ |
| 67 | + <C> CompletableFuture<C> convertSendAndReceive(Object object); |
| 68 | + |
| 69 | + /** |
| 70 | + * Convert the object to a message and send it to the default exchange with the |
| 71 | + * provided routing key. |
| 72 | + * @param routingKey the routing key. |
| 73 | + * @param object the object to convert. |
| 74 | + * @param <C> the expected result type. |
| 75 | + * @return the {@link CompletableFuture}. |
| 76 | + */ |
| 77 | + <C> CompletableFuture<C> convertSendAndReceive(String routingKey, Object object); |
| 78 | + |
| 79 | + /** |
| 80 | + * Convert the object to a message and send it to the provided exchange and |
| 81 | + * routing key. |
| 82 | + * @param exchange the exchange. |
| 83 | + * @param routingKey the routing key. |
| 84 | + * @param object the object to convert. |
| 85 | + * @param <C> the expected result type. |
| 86 | + * @return the {@link CompletableFuture}. |
| 87 | + */ |
| 88 | + <C> CompletableFuture<C> convertSendAndReceive(String exchange, String routingKey, Object object); |
| 89 | + |
| 90 | + /** |
| 91 | + * Convert the object to a message and send it to the default exchange with the |
| 92 | + * default routing key after invoking the {@link MessagePostProcessor}. |
| 93 | + * If the post processor adds a correlationId property, it must be unique. |
| 94 | + * @param object the object to convert. |
| 95 | + * @param messagePostProcessor the post processor. |
| 96 | + * @param <C> the expected result type. |
| 97 | + * @return the {@link CompletableFuture}. |
| 98 | + */ |
| 99 | + <C> CompletableFuture<C> convertSendAndReceive(Object object, MessagePostProcessor messagePostProcessor); |
| 100 | + |
| 101 | + /** |
| 102 | + * Convert the object to a message and send it to the default exchange with the |
| 103 | + * provided routing key after invoking the {@link MessagePostProcessor}. |
| 104 | + * If the post processor adds a correlationId property, it must be unique. |
| 105 | + * @param routingKey the routing key. |
| 106 | + * @param object the object to convert. |
| 107 | + * @param messagePostProcessor the post processor. |
| 108 | + * @param <C> the expected result type. |
| 109 | + * @return the {@link CompletableFuture}. |
| 110 | + */ |
| 111 | + <C> CompletableFuture<C> convertSendAndReceive(String routingKey, Object object, |
| 112 | + MessagePostProcessor messagePostProcessor); |
| 113 | + |
| 114 | + /** |
| 115 | + * Convert the object to a message and send it to the provided exchange and |
| 116 | + * routing key after invoking the {@link MessagePostProcessor}. |
| 117 | + * If the post processor adds a correlationId property, it must be unique. |
| 118 | + * @param exchange the exchange |
| 119 | + * @param routingKey the routing key. |
| 120 | + * @param object the object to convert. |
| 121 | + * @param messagePostProcessor the post processor. |
| 122 | + * @param <C> the expected result type. |
| 123 | + * @return the {@link CompletableFuture}. |
| 124 | + */ |
| 125 | + <C> CompletableFuture<C> convertSendAndReceive(String exchange, String routingKey, Object object, |
| 126 | + MessagePostProcessor messagePostProcessor); |
| 127 | + |
| 128 | + /** |
| 129 | + * Convert the object to a message and send it to the default exchange with the |
| 130 | + * default routing key. |
| 131 | + * @param object the object to convert. |
| 132 | + * @param responseType the response type. |
| 133 | + * @param <C> the expected result type. |
| 134 | + * @return the {@link CompletableFuture}. |
| 135 | + */ |
| 136 | + <C> CompletableFuture<C> convertSendAndReceiveAsType(Object object, ParameterizedTypeReference<C> responseType); |
| 137 | + |
| 138 | + /** |
| 139 | + * Convert the object to a message and send it to the default exchange with the |
| 140 | + * provided routing key. |
| 141 | + * @param routingKey the routing key. |
| 142 | + * @param object the object to convert. |
| 143 | + * @param responseType the response type. |
| 144 | + * @param <C> the expected result type. |
| 145 | + * @return the {@link CompletableFuture}. |
| 146 | + */ |
| 147 | + <C> CompletableFuture<C> convertSendAndReceiveAsType(String routingKey, Object object, |
| 148 | + ParameterizedTypeReference<C> responseType); |
| 149 | + |
| 150 | + /** |
| 151 | + * Convert the object to a message and send it to the provided exchange and |
| 152 | + * routing key. |
| 153 | + * @param exchange the exchange. |
| 154 | + * @param routingKey the routing key. |
| 155 | + * @param object the object to convert. |
| 156 | + * @param responseType the response type. |
| 157 | + * @param <C> the expected result type. |
| 158 | + * @return the {@link CompletableFuture}. |
| 159 | + */ |
| 160 | + <C> CompletableFuture<C> convertSendAndReceiveAsType(String exchange, String routingKey, Object object, |
| 161 | + ParameterizedTypeReference<C> responseType); |
| 162 | + |
| 163 | + /** |
| 164 | + * Convert the object to a message and send it to the default exchange with the |
| 165 | + * default routing key after invoking the {@link MessagePostProcessor}. |
| 166 | + * If the post processor adds a correlationId property, it must be unique. |
| 167 | + * @param object the object to convert. |
| 168 | + * @param messagePostProcessor the post processor. |
| 169 | + * @param responseType the response type. |
| 170 | + * @param <C> the expected result type. |
| 171 | + * @return the {@link CompletableFuture}. |
| 172 | + */ |
| 173 | + <C> CompletableFuture<C> convertSendAndReceiveAsType(Object object, MessagePostProcessor messagePostProcessor, |
| 174 | + ParameterizedTypeReference<C> responseType); |
| 175 | + |
| 176 | + /** |
| 177 | + * Convert the object to a message and send it to the default exchange with the |
| 178 | + * provided routing key after invoking the {@link MessagePostProcessor}. |
| 179 | + * If the post processor adds a correlationId property, it must be unique. |
| 180 | + * @param routingKey the routing key. |
| 181 | + * @param object the object to convert. |
| 182 | + * @param messagePostProcessor the post processor. |
| 183 | + * @param responseType the response type. |
| 184 | + * @param <C> the expected result type. |
| 185 | + * @return the {@link CompletableFuture}. |
| 186 | + */ |
| 187 | + <C> CompletableFuture<C> convertSendAndReceiveAsType(String routingKey, Object object, |
| 188 | + MessagePostProcessor messagePostProcessor, ParameterizedTypeReference<C> responseType); |
| 189 | + |
| 190 | + /** |
| 191 | + * Convert the object to a message and send it to the provided exchange and |
| 192 | + * routing key after invoking the {@link MessagePostProcessor}. |
| 193 | + * If the post processor adds a correlationId property, it must be unique. |
| 194 | + * @param exchange the exchange |
| 195 | + * @param routingKey the routing key. |
| 196 | + * @param object the object to convert. |
| 197 | + * @param messagePostProcessor the post processor. |
| 198 | + * @param responseType the response type. |
| 199 | + * @param <C> the expected result type. |
| 200 | + * @return the {@link CompletableFuture}. |
| 201 | + */ |
| 202 | + <C> CompletableFuture<C> convertSendAndReceiveAsType(String exchange, String routingKey, Object object, |
| 203 | + MessagePostProcessor messagePostProcessor, ParameterizedTypeReference<C> responseType); |
| 204 | + |
| 205 | +} |
0 commit comments