Search in sources :

Example 1 with FixedBackOff

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

the class FixedBackOffTests method maxAttemptsReached.

@Test
public void maxAttemptsReached() {
    FixedBackOff backOff = new FixedBackOff(200L, 2);
    BackOffExecution execution = backOff.start();
    assertEquals(200l, execution.nextBackOff());
    assertEquals(200l, execution.nextBackOff());
    assertEquals(BackOffExecution.STOP, execution.nextBackOff());
}
Also used : BackOffExecution(org.springframework.util.backoff.BackOffExecution) FixedBackOff(org.springframework.util.backoff.FixedBackOff) Test(org.junit.Test)

Example 2 with FixedBackOff

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

the class FixedBackOffTests method liveUpdate.

@Test
public void liveUpdate() {
    FixedBackOff backOff = new FixedBackOff(100L, 1);
    BackOffExecution execution = backOff.start();
    assertEquals(100l, execution.nextBackOff());
    backOff.setInterval(200l);
    backOff.setMaxAttempts(2);
    assertEquals(200l, execution.nextBackOff());
    assertEquals(BackOffExecution.STOP, execution.nextBackOff());
}
Also used : BackOffExecution(org.springframework.util.backoff.BackOffExecution) FixedBackOff(org.springframework.util.backoff.FixedBackOff) Test(org.junit.Test)

Example 3 with FixedBackOff

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

the class FixedBackOffTests method defaultInstance.

@Test
public void defaultInstance() {
    FixedBackOff backOff = new FixedBackOff();
    BackOffExecution execution = backOff.start();
    for (int i = 0; i < 100; i++) {
        assertEquals(FixedBackOff.DEFAULT_INTERVAL, execution.nextBackOff());
    }
}
Also used : BackOffExecution(org.springframework.util.backoff.BackOffExecution) FixedBackOff(org.springframework.util.backoff.FixedBackOff) Test(org.junit.Test)

Example 4 with FixedBackOff

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

the class FixedBackOffTests method startReturnDifferentInstances.

@Test
public void startReturnDifferentInstances() {
    FixedBackOff backOff = new FixedBackOff(100L, 1);
    BackOffExecution execution = backOff.start();
    BackOffExecution execution2 = backOff.start();
    assertEquals(100l, execution.nextBackOff());
    assertEquals(100l, execution2.nextBackOff());
    assertEquals(BackOffExecution.STOP, execution.nextBackOff());
    assertEquals(BackOffExecution.STOP, execution2.nextBackOff());
}
Also used : BackOffExecution(org.springframework.util.backoff.BackOffExecution) FixedBackOff(org.springframework.util.backoff.FixedBackOff) Test(org.junit.Test)

Example 5 with FixedBackOff

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

the class JmsNamespaceHandlerTests method getRecoveryInterval.

private long getRecoveryInterval(String containerBeanName) {
    BackOff backOff = getBackOff(containerBeanName);
    assertEquals(FixedBackOff.class, backOff.getClass());
    return ((FixedBackOff) backOff).getInterval();
}
Also used : FixedBackOff(org.springframework.util.backoff.FixedBackOff) BackOff(org.springframework.util.backoff.BackOff) FixedBackOff(org.springframework.util.backoff.FixedBackOff)

Aggregations

FixedBackOff (org.springframework.util.backoff.FixedBackOff)8 Test (org.junit.Test)7 BackOffExecution (org.springframework.util.backoff.BackOffExecution)6 BackOff (org.springframework.util.backoff.BackOff)2 MessageListener (javax.jms.MessageListener)1 DirectFieldAccessor (org.springframework.beans.DirectFieldAccessor)1 DefaultMessageListenerContainer (org.springframework.jms.listener.DefaultMessageListenerContainer)1 MessageListenerAdapter (org.springframework.jms.listener.adapter.MessageListenerAdapter)1