Skip to content

Commit

Permalink
Fix: exception on simple consume when disconnected immediately (#1253)
Browse files Browse the repository at this point in the history
  • Loading branch information
roeschter authored Nov 15, 2024
1 parent 1bf06d5 commit 2175501
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions src/main/java/io/nats/client/impl/NatsMessageConsumer.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ public void heartbeatError() {
doSub();
}
catch (JetStreamApiException | IOException e) {
setupHbAlarmToTrigger();
pmm.resetTracking();
pmm.initOrResetHeartbeatTimer();
}
}

Expand All @@ -69,20 +70,10 @@ void doSub() throws JetStreamApiException, IOException {
finished.set(true);
}
};
try {
super.initSub(subscriptionMaker.subscribe(mh, userDispatcher, pmm, null));
repull();
stopped.set(false);
finished.set(false);
}
catch (JetStreamApiException | IOException e) {
setupHbAlarmToTrigger();
}
}

private void setupHbAlarmToTrigger() {
pmm.resetTracking();
pmm.initOrResetHeartbeatTimer();
super.initSub(subscriptionMaker.subscribe(mh, userDispatcher, pmm, null));
repull();
stopped.set(false);
finished.set(false);
}

@Override
Expand Down

0 comments on commit 2175501

Please sign in to comment.