Search in sources :

Example 6 with BackOff

use of org.springframework.util.backoff.BackOff in project spring-framework by spring-projects.

the class DefaultMessageListenerContainerTests method applyBackOffRetry.

@Test
public void applyBackOffRetry() {
    BackOff backOff = mock(BackOff.class);
    BackOffExecution execution = mock(BackOffExecution.class);
    given(execution.nextBackOff()).willReturn(50L, BackOffExecution.STOP);
    given(backOff.start()).willReturn(execution);
    DefaultMessageListenerContainer container = createContainer(createFailingContainerFactory());
    container.setBackOff(backOff);
    container.start();
    container.refreshConnectionUntilSuccessful();
    assertThat(container.isRunning()).isFalse();
    verify(backOff).start();
    verify(execution, times(2)).nextBackOff();
}
Also used : BackOffExecution(org.springframework.util.backoff.BackOffExecution) BackOff(org.springframework.util.backoff.BackOff) Test(org.junit.jupiter.api.Test)

Aggregations

BackOff (org.springframework.util.backoff.BackOff)6 Test (org.junit.jupiter.api.Test)5 BackOffExecution (org.springframework.util.backoff.BackOffExecution)3 FixedBackOff (org.springframework.util.backoff.FixedBackOff)3 MessageListener (jakarta.jms.MessageListener)1 DirectFieldAccessor (org.springframework.beans.DirectFieldAccessor)1 DefaultMessageListenerContainer (org.springframework.jms.listener.DefaultMessageListenerContainer)1 MessageListenerAdapter (org.springframework.jms.listener.adapter.MessageListenerAdapter)1