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
@@ -151,10 +152,13 @@ public void checkConsumer() throws IOException {
151
152
* Public API - cancels the consumer, thus deleting the temporary queue, and marks the RpcClient as closed.
152
153
* @throws IOException if an error is encountered
153
154
*/
155
+ @ Override
154
156
public void close () throws IOException {
155
157
if (_consumer != null ) {
156
- _channel .basicCancel (_consumer .getConsumerTag ());
158
+ final String consumerTag = _consumer .getConsumerTag ();
159
+ // set it null before calling basicCancel to make this method idempotent in case of IOException
157
160
_consumer = null ;
161
+ _channel .basicCancel (consumerTag );
158
162
}
159
163
}
160
164
You can’t perform that action at this time.
0 commit comments