Skip to content

Commit c3a5f4e

Browse files
committed
Better workflow for leadership change while simplified consuming.
1 parent 1b84912 commit c3a5f4e

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/main/java/io/nats/client/impl/NatsJetStreamSubscription.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -130,19 +130,20 @@ protected Message _nextUnmanagedNoWait(String expectedPullSubject) throws Interr
130130
case MESSAGE:
131131
return msg;
132132
case STATUS_TERMINUS:
133-
// if the status applies return null, otherwise it's ignored, fall through
133+
// if the status applies, return null, otherwise it's ignored, fall through
134134
if (expectedPullSubject == null || expectedPullSubject.equals(msg.getSubject())) {
135135
return null;
136136
}
137137
break;
138138
case STATUS_ERROR:
139-
// if the status applies throw exception, otherwise it's ignored, fall through
139+
// if the status applies, throw exception, otherwise it's ignored, fall through
140140
if (expectedPullSubject == null || expectedPullSubject.equals(msg.getSubject())) {
141141
throw new JetStreamStatusException(msg.getStatus(), this);
142142
}
143143
break;
144144
}
145-
// Check again when, regular messages might have arrived
145+
// These statuses don't apply to the message that came in,
146+
// so we just loop and move on to the next message.
146147
// 1. Any STATUS_HANDLED
147148
// 2. STATUS_TERMINUS or STATUS_ERRORS that aren't for expected pullSubject
148149
}

0 commit comments

Comments
 (0)