Example usage for org.springframework.amqp.rabbit.core RabbitTemplate RabbitTemplate

List of usage examples for org.springframework.amqp.rabbit.core RabbitTemplate RabbitTemplate

Introduction

In this page you can find the example usage for org.springframework.amqp.rabbit.core RabbitTemplate RabbitTemplate.

Prototype

public RabbitTemplate(ConnectionFactory connectionFactory) 

Source Link

Document

Create a rabbit template with default strategies and settings.

Usage

From source file:lab.example.service.LotteryService.java

@Bean
public RabbitTemplate rabbitTemplate() {
    RabbitTemplate template = new RabbitTemplate(connectionFactory);
    template.setExchange(this.exchangeName);
    return template;
}

From source file:com.bfair.pricing.config.AbstractStockAppRabbitConfiguration.java

@Bean
public RabbitTemplate rabbitTemplate() {
    RabbitTemplate template = new RabbitTemplate(connectionFactory());
    template.setMessageConverter(jsonMessageConverter());
    configureRabbitTemplate(template);/* w  w  w .  ja  v a 2 s.  c  om*/
    return template;
}

From source file:com.sample.amqp.RabbitConfiguration.java

@Bean(name = "rabbitTemplate")
public RabbitTemplate rabbitTemplate() {
    RabbitTemplate rabbitTemplate = new RabbitTemplate(connectionFactory());
    rabbitTemplate.setMessageConverter(jsonMessageConverter());
    rabbitTemplate.setReplyQueue(responseQueue());
    rabbitTemplate.setReplyTimeout(60000);
    return rabbitTemplate;
}

From source file:lab.example.service.MessageListener.java

@Bean
public RabbitTemplate rabbitTemplate() {
    RabbitTemplate template = new RabbitTemplate(connectionFactory);
    template.setExchange(exchangeName);
    return template;
}

From source file:org.cloudfoundry.workers.stocks.integration.service.config.ServiceConfiguration.java

@Bean
public RabbitTemplate rabbitTemplate() throws Throwable {
    RabbitTemplate rabbitTemplate = new RabbitTemplate(
            rabbitConnectionFactoryConfiguration.connectionFactory());
    rabbitTemplate.setMessageConverter(mc());
    return rabbitTemplate;
}

From source file:org.cloudfoundry.workers.stocks.integration.client.ClientConfiguration.java

@Bean
public RabbitTemplate amqpTemplate() throws Throwable {
    RabbitTemplate rabbitTemplate = new RabbitTemplate(
            rabbitConnectionFactoryConfiguration.connectionFactory());
    rabbitTemplate.setMessageConverter(mc());
    return rabbitTemplate;
}

From source file:vn.com.vndirect.api.service.SpringAMQP.java

protected CamelContext addAmqpCamelContext() throws Exception {
    CachingConnectionFactory factory = new CachingConnectionFactory();
    factory.setAddresses(addressesAmqp);
    factory.setUsername(usernameAmqp);//from w  w  w.  ja  v a  2  s  .  c  om
    factory.setPassword(passwordAmqp);
    factory.setPort(5672);
    RabbitTemplate amqpTemplate = new RabbitTemplate(factory);
    amqpTemplate.setMessageConverter(new JsonMessageConverter());
    SpringAMQPComponent amqpComponent = new SpringAMQPComponent(factory);
    amqpComponent.setAmqpTemplate(amqpTemplate);
    context.addComponent("spring-amqp", amqpComponent);
    return context;
}

From source file:io.acme.solution.api.conf.RabbitConfigurer.java

@Bean
public RabbitTemplate getRabbitTemplate(final ConnectionFactory connectionFactory,
        final MessageConverter messageConverter) {

    log.info("Plugging in custom json serializer for RabbitMQ");

    final RabbitTemplate rabbitTemplate = new RabbitTemplate(connectionFactory);
    rabbitTemplate.setMessageConverter(messageConverter);

    return rabbitTemplate;
}

From source file:io.acme.solution.infrastructure.conf.EventBusConfigurer.java

@Bean
@Autowired// w  w  w .j a  v a2s  .com
@Primary
public RabbitTemplate eventBusRabbitTemplate(final ConnectionFactory eventBusConnectionFactory,
        final MessageConverter eventBusMessageConverter) {

    log.info("Creating event bus RabbitMQ template with a custom JSON converter");
    final RabbitTemplate rabbitTemplate = new RabbitTemplate(eventBusConnectionFactory);
    rabbitTemplate.setMessageConverter(eventBusMessageConverter);

    return rabbitTemplate;
}

From source file:acromusashi.stream.component.rabbitmq.AmqpTemplateFactoryTest.java

/**
 * ???//from ww  w  .  j  av a 2s  .c  o  m
 * 
 * @target {@link AmqpTemplateFactory#getAmqpTemplate(String)}
 * @test ???(??null:)
 *    condition:: ??:null
 *    result:: ????
 * 
 * @test ???(??null:)
 *    condition:: ??:null
 *    result:: ??????
 * 
 * @test ???(??:)
 *    condition:: ??:
 *    result:: ????
 * 
 * @test ???(??:)
 *    condition:: ??:
 *    result:: ??????
 * 
 * @test ???(????:??)
 *    condition:: ??:????
 *    result:: ??????
 * 
 * @test ???(????:ConnectionFactory?)
 *    condition:: ??:????
 *    result:: ??ConnectionFactory??????
 * 
 * @test ???(????:?)
 *    condition:: ??:????
 *    result:: 2???1?????????
 * 
 * @test ???(???????:)
 *    condition:: ??:???????
 *    result:: ????
 * 
 * @test ???(???????:)
 *    condition:: ??:???????
 *    result:: ??????
 */
@DataPoints
public static Fixture[] createFixture_QueueName() {
    List<Fixture> patterns = new ArrayList<Fixture>();

    // null
    patterns.add(new Fixture(null, new RabbitmqCommunicateException("QueueName is not defined.")));

    // 
    patterns.add(new Fixture("",
            new RabbitmqCommunicateException("QueueNames ProcessList is not defined. QueueName={0}")));

    // ????
    CachingConnectionFactory connectionFactory = new CachingConnectionFactory();
    connectionFactory.setChannelCacheSize(10);
    patterns.add(new Fixture(DEFINED_QUEUE_NAME, new RabbitTemplate(connectionFactory)));

    // ???????
    patterns.add(new Fixture(NON_DEFINED_QUEUE_NAME,
            new RabbitmqCommunicateException("QueueNames ProcessList is not defined. QueueName={0}")));

    return patterns.toArray(new Fixture[patterns.size()]);
}