File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
src/main/java/com/rabbitmq/client Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change 18
18
19
19
import java .io .ByteArrayInputStream ;
20
20
import java .io .ByteArrayOutputStream ;
21
+ import java .io .Closeable ;
21
22
import java .io .DataInputStream ;
22
23
import java .io .DataOutputStream ;
23
24
import java .io .EOFException ;
44
45
* It simply provides a mechanism for sending a message to an exchange with a given routing key,
45
46
* and waiting for a response.
46
47
*/
47
- public class RpcClient {
48
+ public class RpcClient implements Closeable {
48
49
49
50
private static final Logger LOGGER = LoggerFactory .getLogger (RpcClient .class );
50
51
@@ -236,10 +237,13 @@ public void checkConsumer() throws IOException {
236
237
* Public API - cancels the consumer, thus deleting the temporary queue, and marks the RpcClient as closed.
237
238
* @throws IOException if an error is encountered
238
239
*/
240
+ @ Override
239
241
public void close () throws IOException {
240
242
if (_consumer != null ) {
241
- _channel .basicCancel (_consumer .getConsumerTag ());
243
+ final String consumerTag = _consumer .getConsumerTag ();
244
+ // set it null before calling basicCancel to make this method idempotent in case of IOException
242
245
_consumer = null ;
246
+ _channel .basicCancel (consumerTag );
243
247
}
244
248
}
245
249
You can’t perform that action at this time.
0 commit comments