Search in sources :

Example 11 with RabbitTemplate

use of org.springframework.amqp.rabbit.core.RabbitTemplate in project spring-boot by spring-projects.

the class RabbitAutoConfigurationTests method testConnectionFactoryPublisherSettings.

@Test
public void testConnectionFactoryPublisherSettings() {
    load(TestConfiguration.class, "spring.rabbitmq.publisher-confirms=true", "spring.rabbitmq.publisher-returns=true");
    CachingConnectionFactory connectionFactory = this.context.getBean(CachingConnectionFactory.class);
    RabbitTemplate rabbitTemplate = this.context.getBean(RabbitTemplate.class);
    DirectFieldAccessor dfa = new DirectFieldAccessor(connectionFactory);
    assertThat(dfa.getPropertyValue("publisherConfirms")).isEqualTo(true);
    assertThat(dfa.getPropertyValue("publisherReturns")).isEqualTo(true);
    assertThat(getMandatory(rabbitTemplate)).isTrue();
}
Also used : RabbitTemplate(org.springframework.amqp.rabbit.core.RabbitTemplate) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) CachingConnectionFactory(org.springframework.amqp.rabbit.connection.CachingConnectionFactory) Test(org.junit.Test)

Example 12 with RabbitTemplate

use of org.springframework.amqp.rabbit.core.RabbitTemplate in project spring-boot by spring-projects.

the class RabbitAutoConfigurationTests method testRabbitTemplateMessageConverters.

@Test
public void testRabbitTemplateMessageConverters() {
    load(MessageConvertersConfiguration.class);
    RabbitTemplate rabbitTemplate = this.context.getBean(RabbitTemplate.class);
    assertThat(rabbitTemplate.getMessageConverter()).isSameAs(this.context.getBean("myMessageConverter"));
    DirectFieldAccessor dfa = new DirectFieldAccessor(rabbitTemplate);
    assertThat(dfa.getPropertyValue("retryTemplate")).isNull();
}
Also used : RabbitTemplate(org.springframework.amqp.rabbit.core.RabbitTemplate) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) Test(org.junit.Test)

Example 13 with RabbitTemplate

use of org.springframework.amqp.rabbit.core.RabbitTemplate in project spring-boot by spring-projects.

the class RabbitAutoConfigurationTests method testDefaultRabbitConfiguration.

@Test
public void testDefaultRabbitConfiguration() {
    load(TestConfiguration.class);
    RabbitTemplate rabbitTemplate = this.context.getBean(RabbitTemplate.class);
    RabbitMessagingTemplate messagingTemplate = this.context.getBean(RabbitMessagingTemplate.class);
    CachingConnectionFactory connectionFactory = this.context.getBean(CachingConnectionFactory.class);
    DirectFieldAccessor dfa = new DirectFieldAccessor(connectionFactory);
    RabbitAdmin amqpAdmin = this.context.getBean(RabbitAdmin.class);
    assertThat(rabbitTemplate.getConnectionFactory()).isEqualTo(connectionFactory);
    assertThat(getMandatory(rabbitTemplate)).isFalse();
    assertThat(messagingTemplate.getRabbitTemplate()).isEqualTo(rabbitTemplate);
    assertThat(amqpAdmin).isNotNull();
    assertThat(connectionFactory.getHost()).isEqualTo("localhost");
    assertThat(dfa.getPropertyValue("publisherConfirms")).isEqualTo(false);
    assertThat(dfa.getPropertyValue("publisherReturns")).isEqualTo(false);
    assertThat(this.context.containsBean("rabbitListenerContainerFactory")).as("Listener container factory should be created by default").isTrue();
}
Also used : RabbitTemplate(org.springframework.amqp.rabbit.core.RabbitTemplate) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) RabbitMessagingTemplate(org.springframework.amqp.rabbit.core.RabbitMessagingTemplate) CachingConnectionFactory(org.springframework.amqp.rabbit.connection.CachingConnectionFactory) RabbitAdmin(org.springframework.amqp.rabbit.core.RabbitAdmin) Test(org.junit.Test)

Example 14 with RabbitTemplate

use of org.springframework.amqp.rabbit.core.RabbitTemplate in project av-service by dvoraka.

the class AmqpFileCommonConfig method rabbitTemplate.

@Bean
public RabbitTemplate rabbitTemplate(ConnectionFactory connectionFactory, MessageConverter messageConverter) {
    RabbitTemplate template = new RabbitTemplate(connectionFactory);
    template.setReceiveTimeout(listeningTimeout);
    template.setMessageConverter(messageConverter);
    return template;
}
Also used : RabbitTemplate(org.springframework.amqp.rabbit.core.RabbitTemplate) Bean(org.springframework.context.annotation.Bean)

Aggregations

RabbitTemplate (org.springframework.amqp.rabbit.core.RabbitTemplate)14 Test (org.junit.Test)8 Bean (org.springframework.context.annotation.Bean)6 DirectFieldAccessor (org.springframework.beans.DirectFieldAccessor)4 CachingConnectionFactory (org.springframework.amqp.rabbit.connection.CachingConnectionFactory)3 RabbitAdmin (org.springframework.amqp.rabbit.core.RabbitAdmin)1 RabbitMessagingTemplate (org.springframework.amqp.rabbit.core.RabbitMessagingTemplate)1 ExponentialBackOffPolicy (org.springframework.retry.backoff.ExponentialBackOffPolicy)1 SimpleRetryPolicy (org.springframework.retry.policy.SimpleRetryPolicy)1 RetryTemplate (org.springframework.retry.support.RetryTemplate)1