Search in sources :

Example 6 with FixedBackOff

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

the class FixedBackOffTests method noAttemptAtAll.

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

Example 7 with FixedBackOff

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

the class FixedBackOffTests method toStringContent.

@Test
public void toStringContent() {
    FixedBackOff backOff = new FixedBackOff(200L, 10);
    BackOffExecution execution = backOff.start();
    assertEquals("FixedBackOff{interval=200, currentAttempts=0, maxAttempts=10}", execution.toString());
    execution.nextBackOff();
    assertEquals("FixedBackOff{interval=200, currentAttempts=1, maxAttempts=10}", execution.toString());
    execution.nextBackOff();
    assertEquals("FixedBackOff{interval=200, currentAttempts=2, maxAttempts=10}", execution.toString());
}
Also used : BackOffExecution(org.springframework.util.backoff.BackOffExecution) FixedBackOff(org.springframework.util.backoff.FixedBackOff) Test(org.junit.Test)

Example 8 with FixedBackOff

use of org.springframework.util.backoff.FixedBackOff 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);
    assertSame(backOff, new DirectFieldAccessor(container).getPropertyValue("backOff"));
}
Also used : MessageListenerAdapter(org.springframework.jms.listener.adapter.MessageListenerAdapter) DefaultMessageListenerContainer(org.springframework.jms.listener.DefaultMessageListenerContainer) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) MessageListener(javax.jms.MessageListener) FixedBackOff(org.springframework.util.backoff.FixedBackOff) BackOff(org.springframework.util.backoff.BackOff) FixedBackOff(org.springframework.util.backoff.FixedBackOff) Test(org.junit.Test)

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