Java Code Examples for org.springframework.amqp.rabbit.connection.CachingConnectionFactory#setUsername()

The following examples show how to use org.springframework.amqp.rabbit.connection.CachingConnectionFactory#setUsername() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AmqpTestConfiguration.java    From hawkbit with Eclipse Public License 1.0 6 votes vote down vote up
@Bean
ConnectionFactory rabbitConnectionFactory(final RabbitMqSetupService rabbitmqSetupService) {
    final CachingConnectionFactory factory = new CachingConnectionFactory();
    factory.setHost(rabbitmqSetupService.getHostname());
    factory.setPort(5672);
    factory.setUsername(rabbitmqSetupService.getUsername());
    factory.setPassword(rabbitmqSetupService.getPassword());
    try {
        factory.setVirtualHost(rabbitmqSetupService.createVirtualHost());
        // All exception are catched. The BrokerRunning decide if the
        // test should break or not
    } catch (@SuppressWarnings("squid:S2221") final Exception e) {
        Throwables.propagateIfInstanceOf(e, AlivenessException.class);
        LOG.error("Cannot create virtual host.", e);
    }
    return factory;
}
 
Example 2
Source File: RabbitMQConfiguration.java    From Learning-Path-Spring-5-End-to-End-Programming with MIT License 5 votes vote down vote up
@Bean("springConnectionFactory")
public ConnectionFactory connectionFactory() {
  CachingConnectionFactory factory = new CachingConnectionFactory();
  factory.setUsername(this.user);
  factory.setPassword(this.pass);
  factory.setHost(this.host);
  factory.setPort(this.port);
  return factory;
}
 
Example 3
Source File: RabbitMQConfiguration.java    From Learning-Path-Spring-5-End-to-End-Programming with MIT License 5 votes vote down vote up
@Bean("springConnectionFactory")
public ConnectionFactory connectionFactory() {
  CachingConnectionFactory factory = new CachingConnectionFactory();
  factory.setUsername(this.user);
  factory.setPassword(this.pass);
  factory.setHost(this.host);
  factory.setPort(this.port);
  return factory;
}
 
Example 4
Source File: RabbitMQConfig.java    From kkbinlog with Apache License 2.0 5 votes vote down vote up
@Bean
public ConnectionFactory connectionFactory() {
    CachingConnectionFactory factory = new CachingConnectionFactory();
    factory.setAddresses(host + ":"  + port);
    factory.setVirtualHost(virtualHost);
    factory.setUsername(username);
    factory.setPassword(password);
    return factory;
}
 
Example 5
Source File: RabbitMQConfig.java    From kkbinlog with Apache License 2.0 5 votes vote down vote up
@Bean
public ConnectionFactory connectionFactory() {
    CachingConnectionFactory factory = new CachingConnectionFactory();
    factory.setAddresses(host + ":"  + port);
    factory.setVirtualHost(virtualHost);
    factory.setUsername(username);
    factory.setPassword(password);
    return factory;
}
 
Example 6
Source File: RabbitMQConfig.java    From kkbinlog with Apache License 2.0 5 votes vote down vote up
@Bean
public ConnectionFactory connectionFactory() {
    CachingConnectionFactory factory = new CachingConnectionFactory();
    factory.setAddresses(host + ":"  + port);
    factory.setVirtualHost(virtualHost);
    factory.setUsername(username);
    factory.setPassword(password);
    return factory;
}
 
Example 7
Source File: RabbitConfig.java    From notes with Apache License 2.0 5 votes vote down vote up
/**
 * 注入
 *
 * @param
 * @return com.rabbitmq.client.Connection
 * @author fruiqi
 * @date 19-1-22 下午5:41
 **/
@Bean
public ConnectionFactory getConnection() throws Exception {
    CachingConnectionFactory factory = new CachingConnectionFactory();
    factory.setUsername(userName);
    factory.setPassword(userPassword);
    factory.setHost(host);
    factory.setPort(port);
    return factory;
}
 
Example 8
Source File: RabbitMQConfiguration.java    From Spring-5.0-By-Example with MIT License 5 votes vote down vote up
@Bean("springConnectionFactory")
public ConnectionFactory connectionFactory() {
  CachingConnectionFactory factory = new CachingConnectionFactory();
  factory.setUsername(this.user);
  factory.setPassword(this.pass);
  factory.setHost(this.host);
  factory.setPort(this.port);
  return factory;
}
 
Example 9
Source File: RabbitConfiguration.java    From JuniperBot with GNU General Public License v3.0 5 votes vote down vote up
@Bean
public ConnectionFactory connectionFactory() {
    CommonProperties.RabbitMQ rabbitMQ = commonProperties.getRabbitMQ();
    CachingConnectionFactory factory = new CachingConnectionFactory(rabbitMQ.getHostname(), rabbitMQ.getPort());
    if (rabbitMQ.getUsername() != null && rabbitMQ.getPassword() != null) {
        factory.setUsername(rabbitMQ.getUsername());
        factory.setPassword(rabbitMQ.getPassword());
    }
    return factory;
}
 
Example 10
Source File: AmqpContextConfig.java    From sinavi-jfw with Apache License 2.0 5 votes vote down vote up
/**
 * {@link ConnectionFactory}のインスタンスをDIコンテナに登録します。
 * @return {@link CachingConnectionFactory}のインスタンス
 */
@Bean
public ConnectionFactory factory() {
    CachingConnectionFactory connectionFactory = new CachingConnectionFactory(host, Integer.valueOf(port));
    connectionFactory.setUsername(username);
    connectionFactory.setPassword(password);
    connectionFactory.setChannelCacheSize(channelCacheSize);
    configure(connectionFactory);
    return connectionFactory;
}
 
Example 11
Source File: RabbitMQInitializerTest.java    From sinavi-jfw with Apache License 2.0 5 votes vote down vote up
@Bean
public ConnectionFactory factory() {
    CachingConnectionFactory connectionFactory = new CachingConnectionFactory("127.0.0.1");
    connectionFactory.setUsername("guest");
    connectionFactory.setPassword("guest");
    return connectionFactory;
}
 
Example 12
Source File: RabbitMQLocalConfig.java    From bearchoke with Apache License 2.0 5 votes vote down vote up
/**
 * Bean is our direct connection to RabbitMQ
 * @return CachingConnectionFactory
 */
@Bean(destroyMethod = "destroy")
public ConnectionFactory rabbitConnectionFactory() {
    CachingConnectionFactory factory = new CachingConnectionFactory(
            environment.getProperty("rabbitmq.host"),
            environment.getProperty("rabbitmq.port", Integer.class)
    );
    factory.setUsername(environment.getProperty("rabbitmq.username"));
    factory.setPassword(environment.getProperty("rabbitmq.password"));

    return factory;
}
 
Example 13
Source File: ListenerJobBuilder.java    From elastic-rabbitmq with MIT License 4 votes vote down vote up
public static ConnectionFactory getConnectionFactory() {
    CachingConnectionFactory connectionFactory = new CachingConnectionFactory("10.128.165.206");
    connectionFactory.setUsername("guest");
    connectionFactory.setPassword("guest");
    return connectionFactory;
}