MessageListenerThread extends Thread { void checkSlowProcess(long elapsed, double longProcessThreshold) { if (elapsed > longProcessThreshold) { logger.warn(errorCode("LONG_PROCESS"), "took too long to process message, elapsed={}", Duration.ofNanos(elapsed)); } } MessageListenerThread(String name, MessageListener listener); @Override void run();  }
@Test void checkSlowProcess() { thread.checkSlowProcess(Duration.ofSeconds(30).toNanos(), Duration.ofSeconds(25).toNanos()); }