/** * Set the maximum number of release attempts for when message release fails. * Default {@value DelayHandler#DEFAULT_MAX_ATTEMPTS}. * @param maxAttempts the max attempts. * @return the endpoint spec. * @see #retryDelay(long) * @since 5.0.8 */ public DelayerEndpointSpec maxAttempts(int maxAttempts) { this.handler.setMaxAttempts(maxAttempts); return this; }
@Test public void testLateReply() { ConfigurableApplicationContext ac = new ClassPathXmlApplicationContext("GatewayInterfaceTests-context.xml", getClass()); DelayHandler delayHandler = ac.getBean(DelayHandler.class); delayHandler.setMaxAttempts(2); delayHandler.setRetryDelay(10); Bar baz = ac.getBean(Bar.class); String reply = baz.lateReply("hello", 1000, 0); assertNull(reply); PollableChannel errorChannel = ac.getBean("errorChannel", PollableChannel.class); Message<?> receive = errorChannel.receive(10000); assertNotNull(receive); MessagingException messagingException = (MessagingException) receive.getPayload(); assertThat(messagingException.getMessage(), startsWith("Reply message received but the receiving thread has exited due to a timeout")); ac.close(); }
/** * Set the maximum number of release attempts for when message release fails. * Default {@value DelayHandler#DEFAULT_MAX_ATTEMPTS}. * @param maxAttempts the max attempts. * @return the endpoint spec. * @see #retryDelay(long) * @since 5.0.8 */ public DelayerEndpointSpec maxAttempts(int maxAttempts) { this.handler.setMaxAttempts(maxAttempts); return this; }