Skip to content

Commit

Permalink
allow tasks to be rejected (#1817)
Browse files Browse the repository at this point in the history
  • Loading branch information
moscicky authored Jan 18, 2024
1 parent dc131fa commit 187b31a
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import java.time.Duration;
import java.util.Optional;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.RejectedExecutionException;
import java.util.function.Supplier;

public class BrokerLatencyReporter {
Expand Down Expand Up @@ -39,7 +40,12 @@ public void report(HermesTimerContext timerContext,
@Nullable Supplier<ProduceMetadata> produceMetadata) {
Duration duration = timerContext.closeAndGet();
if (perBrokerLatencyEnabled) {
reporterExecutorService.submit(() -> doReport(duration, message.getId(), ack, produceMetadata));
try {
reporterExecutorService.submit(() -> doReport(duration, message.getId(), ack, produceMetadata));
} catch (RejectedExecutionException ignored) {
// don't propagate the exception - allow metrics to be dropped if executor is overloaded
// executor service should already be instrumented to meter rejected executions so no action is needed
}
}

}
Expand Down

0 comments on commit 187b31a

Please sign in to comment.