Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs - close() versus stop() in MessageConsumer #1271

Merged
merged 2 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/main/java/io/nats/client/JetStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,10 @@
*
* js.publish("foo.joe", "Hello World".getBytes());
*
* //Wait a moment, then stop the MessageConsumer
* //Wait a moment, then stop and close the MessageConsumer
* Thread.sleep(3000);
* mc.stop();
* mc.stop(); //Stops pull requests
* mc.close(); //Unsubcribes
*
* </pre>
*
Expand Down
8 changes: 7 additions & 1 deletion src/main/java/io/nats/client/MessageConsumer.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,17 @@ public interface MessageConsumer extends AutoCloseable {
ConsumerInfo getCachedConsumerInfo();

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

/**
* Unsubscribe the underlying subject. Close will be lenient. In flight and buffered messages may still be delivered.
*/
@Override
void close() throws Exception;

/**
* Stopped indicates whether consuming has been stopped. Can be stopped without being finished.
* @return the stopped flag
Expand Down
Loading