Package org.springframework.util.backoff

Examples of org.springframework.util.backoff.BackOff


*/
public class DefaultMessageListenerContainerTests {

  @Test
  public void applyBackOff() {
    BackOff mock = mock(BackOff.class);
    BackOffExecution execution = mock(BackOffExecution.class);
    given(execution.nextBackOff()).willReturn(BackOffExecution.STOP);
    given(mock.start()).willReturn(execution);

    DefaultMessageListenerContainer container = createContainer(mock, createFailingContainerFactory());
    container.start();
    assertEquals(true, container.isRunning());

View Full Code Here


    verify(execution).nextBackOff();
  }

  @Test
  public void applyBackOffRetry() {
    BackOff mock = mock(BackOff.class);
    BackOffExecution execution = mock(BackOffExecution.class);
    given(execution.nextBackOff()).willReturn(50L, BackOffExecution.STOP);
    given(mock.start()).willReturn(execution);

    DefaultMessageListenerContainer container = createContainer(mock, createFailingContainerFactory());
    container.start();
    container.refreshConnectionUntilSuccessful();
View Full Code Here

    verify(execution, times(2)).nextBackOff();
  }

  @Test
  public void recoverResetBackOff() {
    BackOff mock = mock(BackOff.class);
    BackOffExecution execution = mock(BackOffExecution.class);
    given(execution.nextBackOff()).willReturn(50L, 50L, 50L); // 3 attempts max
    given(mock.start()).willReturn(execution);

    DefaultMessageListenerContainer container = createContainer(mock, createRecoverableContainerFactory(1));
    container.start();
    container.refreshConnectionUntilSuccessful();
View Full Code Here

  }

  @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();
View Full Code Here

  }

  @Test
  public void testRecoveryInterval() {
    Object testBackOff = context.getBean("testBackOff");
    BackOff backOff1 = getBackOff("listener1");
    BackOff backOff2 = getBackOff("listener2");
    long recoveryInterval3 = getRecoveryInterval(DefaultMessageListenerContainer.class.getName() + "#0");

    assertSame(testBackOff, backOff1);
    assertSame(testBackOff, backOff2);
    assertEquals(DefaultMessageListenerContainer.DEFAULT_RECOVERY_INTERVAL, recoveryInterval3);
View Full Code Here

    DefaultMessageListenerContainer container = this.context.getBean(containerBeanName, DefaultMessageListenerContainer.class);
    return (BackOff) new DirectFieldAccessor(container).getPropertyValue("backOff");
  }

  private long getRecoveryInterval(String containerBeanName) {
    BackOff backOff = getBackOff(containerBeanName);
    assertEquals(FixedBackOff.class, backOff.getClass());
    return ((FixedBackOff)backOff).getInterval();
  }
View Full Code Here

TOP

Related Classes of org.springframework.util.backoff.BackOff

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.