use of org.springframework.amqp.rabbit.core.RabbitTemplate in project spring-boot by spring-projects.
the class RabbitAutoConfigurationTests method testRabbitTemplateRetry.
@Test
public void testRabbitTemplateRetry() {
load(TestConfiguration.class, "spring.rabbitmq.template.retry.enabled:true", "spring.rabbitmq.template.retry.maxAttempts:4", "spring.rabbitmq.template.retry.initialInterval:2000", "spring.rabbitmq.template.retry.multiplier:1.5", "spring.rabbitmq.template.retry.maxInterval:5000", "spring.rabbitmq.template.receiveTimeout:123", "spring.rabbitmq.template.replyTimeout:456");
RabbitTemplate rabbitTemplate = this.context.getBean(RabbitTemplate.class);
DirectFieldAccessor dfa = new DirectFieldAccessor(rabbitTemplate);
assertThat(dfa.getPropertyValue("receiveTimeout")).isEqualTo(123L);
assertThat(dfa.getPropertyValue("replyTimeout")).isEqualTo(456L);
RetryTemplate retryTemplate = (RetryTemplate) dfa.getPropertyValue("retryTemplate");
assertThat(retryTemplate).isNotNull();
dfa = new DirectFieldAccessor(retryTemplate);
SimpleRetryPolicy retryPolicy = (SimpleRetryPolicy) dfa.getPropertyValue("retryPolicy");
ExponentialBackOffPolicy backOffPolicy = (ExponentialBackOffPolicy) dfa.getPropertyValue("backOffPolicy");
assertThat(retryPolicy.getMaxAttempts()).isEqualTo(4);
assertThat(backOffPolicy.getInitialInterval()).isEqualTo(2000);
assertThat(backOffPolicy.getMultiplier()).isEqualTo(1.5);
assertThat(backOffPolicy.getMaxInterval()).isEqualTo(5000);
}
use of org.springframework.amqp.rabbit.core.RabbitTemplate in project spring-boot by spring-projects.
the class RabbitAutoConfigurationTests method testRabbitTemplateBackOff.
@Test
public void testRabbitTemplateBackOff() {
load(TestConfiguration3.class);
RabbitTemplate rabbitTemplate = this.context.getBean(RabbitTemplate.class);
assertThat(rabbitTemplate.getMessageConverter()).isEqualTo(this.context.getBean("testMessageConverter"));
}
use of org.springframework.amqp.rabbit.core.RabbitTemplate in project spring-boot by spring-projects.
the class RabbitAutoConfigurationTests method testConnectionFactoryBackOff.
@Test
public void testConnectionFactoryBackOff() {
load(TestConfiguration2.class);
RabbitTemplate rabbitTemplate = this.context.getBean(RabbitTemplate.class);
CachingConnectionFactory connectionFactory = this.context.getBean(CachingConnectionFactory.class);
assertThat(connectionFactory).isEqualTo(rabbitTemplate.getConnectionFactory());
assertThat(connectionFactory.getHost()).isEqualTo("otherserver");
assertThat(connectionFactory.getPort()).isEqualTo(8001);
}
use of org.springframework.amqp.rabbit.core.RabbitTemplate in project spring-boot by spring-projects.
the class RabbitAutoConfigurationTests method testRabbitTemplateMandatoryDisabledEvenIfPublisherReturnsIsSet.
@Test
public void testRabbitTemplateMandatoryDisabledEvenIfPublisherReturnsIsSet() {
load(TestConfiguration.class, "spring.rabbitmq.template.mandatory:false", "spring.rabbitmq.publisher-returns=true");
RabbitTemplate rabbitTemplate = this.context.getBean(RabbitTemplate.class);
assertThat(getMandatory(rabbitTemplate)).isFalse();
}
use of org.springframework.amqp.rabbit.core.RabbitTemplate in project spring-boot by spring-projects.
the class RabbitAutoConfigurationTests method testRabbitTemplateMandatory.
@Test
public void testRabbitTemplateMandatory() {
load(TestConfiguration.class, "spring.rabbitmq.template.mandatory:true");
RabbitTemplate rabbitTemplate = this.context.getBean(RabbitTemplate.class);
assertThat(getMandatory(rabbitTemplate)).isTrue();
}
Aggregations