Example usage for org.springframework.amqp.rabbit.connection CachingConnectionFactory setAddresses

List of usage examples for org.springframework.amqp.rabbit.connection CachingConnectionFactory setAddresses

Introduction

In this page you can find the example usage for org.springframework.amqp.rabbit.connection CachingConnectionFactory setAddresses.

Prototype

public void setAddresses(String addresses) 

Source Link

Document

Set addresses for clustering.

Usage

From source file:io.manasobi.commons.config.AmqpConfig.java

@Bean
public ConnectionFactory rabbitConnectionFactory() {

    CachingConnectionFactory connectionFactory = new CachingConnectionFactory();

    connectionFactory.setAddresses("192.168.0.9");
    connectionFactory.setVirtualHost("manasobi-host");
    connectionFactory.setUsername("manasobi");
    connectionFactory.setPassword("manasobi");

    return connectionFactory;
}

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 www  .j  a va 2s .c o  m*/
    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:org.opentestsystem.delivery.logging.RabbitConfiguration.java

@Bean
public ConnectionFactory connectionFactory() {
    final CachingConnectionFactory factory = new CachingConnectionFactory(determineHost());
    if (isNotBlank(addresses)) {
        factory.setAddresses(addresses);
    }//  w w w.  ja  v  a  2s  .  c  o  m
    factory.setPort(port);
    factory.setUsername(username);
    factory.setPassword(password);
    factory.setVirtualHost(vhost);
    return factory;
}

From source file:org.springframework.amqp.rabbit.connection.CachingConnectionFactoryTests.java

@Test
public void setAddressesEmpty() throws Exception {
    ConnectionFactory mock = mock(com.rabbitmq.client.ConnectionFactory.class);
    CachingConnectionFactory ccf = new CachingConnectionFactory(mock);
    ccf.setExecutor(mock(ExecutorService.class));
    ccf.setHost("abc");
    ccf.setAddresses("");
    ccf.createConnection();/*  w w w.  jav a 2 s.  c  o  m*/
    verify(mock).isAutomaticRecoveryEnabled();
    verify(mock).setHost("abc");
    Log logger = TestUtils.getPropertyValue(ccf, "logger", Log.class);
    if (logger.isInfoEnabled()) {
        verify(mock).getHost();
        verify(mock).getPort();
    }
    verify(mock).newConnection(any(ExecutorService.class), anyString());
    verifyNoMoreInteractions(mock);
}

From source file:org.springframework.amqp.rabbit.connection.CachingConnectionFactoryTests.java

@Test
public void setAddressesOneHost() throws Exception {
    ConnectionFactory mock = mock(com.rabbitmq.client.ConnectionFactory.class);
    CachingConnectionFactory ccf = new CachingConnectionFactory(mock);
    ccf.setAddresses("mq1");
    ccf.createConnection();/*from   ww w .  j  a va2s .  c  o  m*/
    verify(mock).isAutomaticRecoveryEnabled();
    verify(mock).newConnection(isNull(), aryEq(new Address[] { new Address("mq1") }), anyString());
    verifyNoMoreInteractions(mock);
}

From source file:org.springframework.amqp.rabbit.connection.CachingConnectionFactoryTests.java

@Test
public void setAddressesTwoHosts() throws Exception {
    ConnectionFactory mock = mock(com.rabbitmq.client.ConnectionFactory.class);
    doReturn(true).when(mock).isAutomaticRecoveryEnabled();
    CachingConnectionFactory ccf = new CachingConnectionFactory(mock);
    ccf.setAddresses("mq1,mq2");
    ccf.createConnection();//from  www.j a  va2 s .  co  m
    verify(mock).isAutomaticRecoveryEnabled();
    verify(mock).newConnection(isNull(), aryEq(new Address[] { new Address("mq1"), new Address("mq2") }),
            anyString());
    verifyNoMoreInteractions(mock);
}

From source file:org.springframework.amqp.rabbit.connection.LocalizedQueueConnectionFactory.java

/**
 * Create a dedicated connection factory for the address.
 * @param address the address to which the factory should connect.
 * @param node  the node.//from w w w  .j av a2 s . c  om
 * @return the connection factory.
 * @throws Exception if errors occur during creation.
 */
protected ConnectionFactory createConnectionFactory(String address, String node) throws Exception {
    RabbitConnectionFactoryBean rcfb = new RabbitConnectionFactoryBean();
    rcfb.setUseSSL(this.useSSL);
    rcfb.setSslPropertiesLocation(this.sslPropertiesLocation);
    rcfb.setKeyStore(this.keyStore);
    rcfb.setTrustStore(this.trustStore);
    rcfb.setKeyStorePassphrase(this.keyStorePassPhrase);
    rcfb.setTrustStorePassphrase(this.trustStorePassPhrase);
    rcfb.afterPropertiesSet();
    CachingConnectionFactory ccf = new CachingConnectionFactory(rcfb.getObject());
    ccf.setAddresses(address);
    ccf.setUsername(this.username);
    ccf.setPassword(this.password);
    ccf.setVirtualHost(this.vhost);
    ccf.setBeanName("node:" + node);
    return ccf;
}

From source file:org.springframework.cloud.stream.binder.rabbit.LocalizedQueueConnectionFactory.java

/**
 * Create a dedicated connection factory for the address.
 * @param address the address to which the factory should connect.
 * @return the connection factory.//from   ww  w  .ja  va2  s.co  m
 * @throws Exception if errors occur during creation.
 */
protected ConnectionFactory createConnectionFactory(String address) throws Exception {
    RabbitConnectionFactoryBean rcfb = new RabbitConnectionFactoryBean();
    rcfb.setUseSSL(this.useSSL);
    rcfb.setSslPropertiesLocation(this.sslPropertiesLocation);
    rcfb.afterPropertiesSet();
    CachingConnectionFactory ccf = new CachingConnectionFactory(rcfb.getObject());
    ccf.setAddresses(address);
    ccf.setUsername(this.username);
    ccf.setPassword(this.password);
    ccf.setVirtualHost(this.vhost);
    return ccf;
}