Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,8 @@ && shouldRetryOnClientError(retryClientErrors, result))
.withStopStrategy(
attempt ->
attempt.getDelaySinceFirstAttempt() > messageTtlMillis
|| Thread.currentThread().isInterrupted())
|| Thread.currentThread().isInterrupted()
|| !consuming)
.withRetryListener(
getRetryListener(
result -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,7 @@ public void run() {
} finally {
logger.info("Releasing consumer process thread of subscription {}", getSubscriptionName());
refreshHealthcheck();
try {
stop();
} catch (Exception exceptionWhileStopping) {
logger.error(
"An error occurred while stopping consumer process of subscription {}",
getSubscriptionName(),
exceptionWhileStopping);
} finally {
onConsumerStopped.accept(getSubscriptionName());
Thread.currentThread().setName("consumer-released-thread");
}
stop();
}
}

Expand Down Expand Up @@ -119,7 +109,7 @@ private void process(Signal signal) {
"Stopping main loop for consumer {}. {}",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we'd like to to move this logger.info to the stop() method (or maybe we don't need it anymore as we have logger.info("Stopping consumer for subscription {}", getSubscriptionName()). It would be consistent with the other signal types logic.

signal.getTarget(),
signal.getLogWithIdAndType());
this.running = false;
stop();
break;
case RETRANSMIT:
retransmit(signal);
Expand Down Expand Up @@ -159,15 +149,27 @@ private void start(Signal signal) {
}

private void stop() {
long startTime = clock.millis();
logger.info("Stopping consumer for subscription {}", getSubscriptionName());

consumer.tearDown();

logger.info(
"Stopped consumer for subscription {} in {}ms",
getSubscriptionName(),
clock.millis() - startTime);
if (!running) {
return;
}
this.running = false;
try {
long startTime = clock.millis();
logger.info("Stopping consumer for subscription {}", getSubscriptionName());
consumer.tearDown();
logger.info(
"Stopped consumer for subscription {} in {}ms",
getSubscriptionName(),
clock.millis() - startTime);
} catch (Exception exceptionWhileStopping) {
logger.error(
"An error occurred while stopping consumer process of subscription {}",
getSubscriptionName(),
exceptionWhileStopping);
} finally {
onConsumerStopped.accept(getSubscriptionName());
Thread.currentThread().setName("consumer-released-thread");
}
}

private void retransmit(Signal signal) {
Expand Down
Loading