use of org.springframework.util.backoff.BackOffExecution in project spring-framework by spring-projects.
the class FixedBackOffTests method maxAttemptsReached.
@Test
void maxAttemptsReached() {
FixedBackOff backOff = new FixedBackOff(200L, 2);
BackOffExecution execution = backOff.start();
assertThat(execution.nextBackOff()).isEqualTo(200L);
assertThat(execution.nextBackOff()).isEqualTo(200L);
assertThat(execution.nextBackOff()).isEqualTo(BackOffExecution.STOP);
}
use of org.springframework.util.backoff.BackOffExecution in project spring-framework by spring-projects.
the class DefaultMessageListenerContainerTests method recoverResetBackOff.
@Test
public void recoverResetBackOff() {
BackOff backOff = mock(BackOff.class);
BackOffExecution execution = mock(BackOffExecution.class);
// 3 attempts max
given(execution.nextBackOff()).willReturn(50L, 50L, 50L);
given(backOff.start()).willReturn(execution);
DefaultMessageListenerContainer container = createContainer(createRecoverableContainerFactory(1));
container.setBackOff(backOff);
container.start();
container.refreshConnectionUntilSuccessful();
assertThat(container.isRunning()).isTrue();
verify(backOff).start();
// only on attempt as the second one lead to a recovery
verify(execution, times(1)).nextBackOff();
}
use of org.springframework.util.backoff.BackOffExecution in project spring-framework by spring-projects.
the class DefaultMessageListenerContainerTests method applyBackOff.
@Test
public void applyBackOff() {
BackOff backOff = mock(BackOff.class);
BackOffExecution execution = mock(BackOffExecution.class);
given(execution.nextBackOff()).willReturn(BackOffExecution.STOP);
given(backOff.start()).willReturn(execution);
DefaultMessageListenerContainer container = createContainer(createFailingContainerFactory());
container.setBackOff(backOff);
container.start();
assertThat(container.isRunning()).isTrue();
container.refreshConnectionUntilSuccessful();
assertThat(container.isRunning()).isFalse();
verify(backOff).start();
verify(execution).nextBackOff();
}
use of org.springframework.util.backoff.BackOffExecution 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();
}
use of org.springframework.util.backoff.BackOffExecution in project spring-framework by spring-projects.
the class FixedBackOffTests method noAttemptAtAll.
@Test
void noAttemptAtAll() {
FixedBackOff backOff = new FixedBackOff(100L, 0L);
BackOffExecution execution = backOff.start();
assertThat(execution.nextBackOff()).isEqualTo(BackOffExecution.STOP);
}
Aggregations