use of org.springframework.util.backoff.BackOff in project spring-framework by spring-projects.
the class JmsNamespaceHandlerTests method getRecoveryInterval.
private long getRecoveryInterval(String containerBeanName) {
BackOff backOff = getBackOff(containerBeanName);
assertThat(backOff.getClass()).isEqualTo(FixedBackOff.class);
return ((FixedBackOff) backOff).getInterval();
}
use of org.springframework.util.backoff.BackOff in project spring-framework by spring-projects.
the class JmsNamespaceHandlerTests method testRecoveryInterval.
@Test
public void testRecoveryInterval() {
Object testBackOff = context.getBean("testBackOff");
BackOff backOff1 = getBackOff("listener1");
BackOff backOff2 = getBackOff("listener2");
long recoveryInterval3 = getRecoveryInterval(DefaultMessageListenerContainer.class.getName() + "#0");
assertThat(backOff1).isSameAs(testBackOff);
assertThat(backOff2).isSameAs(testBackOff);
assertThat(recoveryInterval3).isEqualTo(DefaultMessageListenerContainer.DEFAULT_RECOVERY_INTERVAL);
}
use of org.springframework.util.backoff.BackOff in project spring-framework by spring-projects.
the class JmsListenerContainerFactoryTests method backOffOverridesRecoveryInterval.
@Test
public void backOffOverridesRecoveryInterval() {
DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
BackOff backOff = new FixedBackOff();
factory.setBackOff(backOff);
factory.setRecoveryInterval(2000L);
SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint();
MessageListener messageListener = new MessageListenerAdapter();
endpoint.setMessageListener(messageListener);
endpoint.setDestination("myQueue");
DefaultMessageListenerContainer container = factory.createListenerContainer(endpoint);
assertThat(new DirectFieldAccessor(container).getPropertyValue("backOff")).isSameAs(backOff);
}
use of org.springframework.util.backoff.BackOff 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.BackOff 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();
}
Aggregations