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

For JS Subs, expose the consumer name since it's already tracked #869

Merged
merged 2 commits into from
Mar 24, 2023
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
6 changes: 6 additions & 0 deletions src/main/java/io/nats/client/JetStreamSubscription.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@
*/
public interface JetStreamSubscription extends Subscription {

/**
* Gets the consumer name that was used to create the subscription.
* @return the consumer name
*/
String getConsumerName();

/**
* Initiate pull with the specified batch size.
* ! Pull subscriptions only. Push subscription will throw IllegalStateException
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ private String supplyMessage(String label, Connection conn, Consumer consumer, S
}
if (sub != null) {
sb.append(", Subscription: ").append(sub.hashCode());
if (sub instanceof JetStreamSubscription) {
JetStreamSubscription jssub = (JetStreamSubscription)sub;
sb.append(", Consumer Name: ").append(jssub.getConsumerName());
}
}
for (int x = 0; x < pairs.length; x++) {
sb.append(", ").append(pairs[x]).append(pairs[++x]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ void setConsumerName(String consumerName) {
this.consumerName = consumerName;
}

String getConsumerName() {
@Override
public String getConsumerName() {
return consumerName;
}

Expand Down