Skip to content

Commit a48f61e

Browse files
authored
Docs - close() versus stop() in MessageConsumer (#1271)
* Docs - close() versus stop() in MessageConsumer * Update MessageConsumer.java
1 parent 366ae9f commit a48f61e

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/main/java/io/nats/client/JetStream.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,10 @@
7373
*
7474
* js.publish("foo.joe", "Hello World".getBytes());
7575
*
76-
* //Wait a moment, then stop the MessageConsumer
76+
* //Wait a moment, then stop and close the MessageConsumer
7777
* Thread.sleep(3000);
78-
* mc.stop();
78+
* mc.stop(); //Stops pull requests
79+
* mc.close(); //Unsubcribes
7980
*
8081
* </pre>
8182
*

src/main/java/io/nats/client/MessageConsumer.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,17 @@ public interface MessageConsumer extends AutoCloseable {
4646
ConsumerInfo getCachedConsumerInfo();
4747

4848
/**
49-
* Stop the MessageConsumer from asking for any more messages from the server.
49+
* Use {@link close()} to unsubscribe. Stop will not unsubcribe or clean up resources.
5050
* The consumer will finish all pull request already in progress, but will not start any new ones.
5151
*/
5252
void stop();
5353

54+
/**
55+
* Unsubscribe the underlying subject. Close will be lenient. In flight and buffered messages may still be delivered.
56+
*/
57+
@Override
58+
void close() throws Exception;
59+
5460
/**
5561
* Stopped indicates whether consuming has been stopped. Can be stopped without being finished.
5662
* @return the stopped flag

0 commit comments

Comments
 (0)