@Test public void testWithCustomKeyGenerator() throws Exception { final CountDownLatch latch = new CountDownLatch(1); StatefulRetryOperationsInterceptor interceptor = RetryInterceptorBuilder.stateful() .messageKeyGenerator(message -> { latch.countDown(); return "foo"; }) .build(); assertEquals(3, TestUtils.getPropertyValue(interceptor, "retryOperations.retryPolicy.maxAttempts")); final AtomicInteger count = new AtomicInteger(); Foo delegate = createDelegate(interceptor, count); Message message = MessageBuilder.withBody("".getBytes()).setRedelivered(false).build(); try { delegate.onMessage("", message); } catch (RuntimeException e) { assertEquals("foo", e.getMessage()); } assertEquals(1, count.get()); assertTrue(latch.await(0, TimeUnit.SECONDS)); }