Java 类org.springframework.boot.autoconfigure.amqp.RabbitProperties 实例源码

项目:spring-cloud-stream-binder-rabbit    文件:RabbitServiceAutoConfiguration.java   
/**
 * Creates a {@link ConnectionFactory} using the singleton service connector.
 * @param cloud {@link Cloud} instance to be used for accessing services.
 * @param connectorConfigObjectProvider the {@link ObjectProvider} for the
 * {@link RabbitConnectionFactoryConfig}.
 * @return the {@link ConnectionFactory} used by the binder.
 */
@Bean
@Primary
ConnectionFactory rabbitConnectionFactory(Cloud cloud,
        ObjectProvider<RabbitConnectionFactoryConfig> connectorConfigObjectProvider,
        ConfigurableApplicationContext applicationContext,
        RabbitProperties rabbitProperties) throws Exception {

    ConnectionFactory connectionFactory = cloud.getSingletonServiceConnector(ConnectionFactory.class,
            connectorConfigObjectProvider.getIfUnique());

    configureCachingConnectionFactory((CachingConnectionFactory) connectionFactory,
            applicationContext, rabbitProperties);

    return connectionFactory;
}
项目:spring-cloud-stream-binder-rabbit    文件:RabbitServiceAutoConfiguration.java   
static void configureCachingConnectionFactory(CachingConnectionFactory connectionFactory,
        ConfigurableApplicationContext applicationContext, RabbitProperties rabbitProperties) throws Exception {

    if (StringUtils.hasText(rabbitProperties.getAddresses())) {
        connectionFactory.setAddresses(rabbitProperties.determineAddresses());
    }

    connectionFactory.setPublisherConfirms(rabbitProperties.isPublisherConfirms());
    connectionFactory.setPublisherReturns(rabbitProperties.isPublisherReturns());
    if (rabbitProperties.getCache().getChannel().getSize() != null) {
        connectionFactory.setChannelCacheSize(rabbitProperties.getCache().getChannel().getSize());
    }
    if (rabbitProperties.getCache().getConnection().getMode() != null) {
        connectionFactory.setCacheMode(rabbitProperties.getCache().getConnection().getMode());
    }
    if (rabbitProperties.getCache().getConnection().getSize() != null) {
        connectionFactory.setConnectionCacheSize(
                rabbitProperties.getCache().getConnection().getSize());
    }
    if (rabbitProperties.getCache().getChannel().getCheckoutTimeout() != null) {
        connectionFactory.setChannelCheckoutTimeout(
                rabbitProperties.getCache().getChannel().getCheckoutTimeout());
    }
    connectionFactory.setApplicationContext(applicationContext);
    applicationContext.addApplicationListener(connectionFactory);
    connectionFactory.afterPropertiesSet();
}
项目:spring-cloud-stream-binder-rabbit    文件:RabbitMessageChannelBinder.java   
public RabbitMessageChannelBinder(ConnectionFactory connectionFactory, RabbitProperties rabbitProperties,
        RabbitExchangeQueueProvisioner provisioningProvider) {
    super(new String[0], provisioningProvider);
    Assert.notNull(connectionFactory, "connectionFactory must not be null");
    Assert.notNull(rabbitProperties, "rabbitProperties must not be null");
    this.connectionFactory = connectionFactory;
    this.rabbitProperties = rabbitProperties;
}
项目:spring-cloud-stream-binder-rabbit    文件:RabbitBinderTests.java   
@Override
protected RabbitTestBinder getBinder() {
    if (this.testBinder == null) {
        RabbitProperties rabbitProperties = new RabbitProperties();
        rabbitProperties.setPublisherConfirms(true);
        rabbitProperties.setPublisherReturns(true);
        this.testBinder = new RabbitTestBinder(rabbitAvailableRule.getResource(), rabbitProperties);
    }
    return this.testBinder;
}
项目:hawkbit    文件:RabbitMqSetupService.java   
public RabbitMqSetupService(RabbitProperties properties) {
    hostname = properties.getHost();
    username = properties.getUsername();
    if (StringUtils.isEmpty(username)) {
        username = DEFAULT_USER;
    }

    password = properties.getPassword();
    if (StringUtils.isEmpty(password)) {
        password = DEFAULT_PASSWORD;
    }

}
项目:spring-cloud-sleuth    文件:ZipkinRabbitSenderConfiguration.java   
@Bean Sender rabbitSender(CachingConnectionFactory connectionFactory, RabbitProperties config) {
    return RabbitMQSender.newBuilder()
            .connectionFactory(connectionFactory.getRabbitConnectionFactory())
            .queue(this.queue)
            .addresses(config.determineAddresses())
            .build();
}
项目:spring-cloud-stream-binder-rabbit    文件:RabbitMessageChannelBinderConfiguration.java   
/**
 * @see org.springframework.boot.autoconfigure.amqp.RabbitAutoConfiguration.RabbitConnectionFactoryCreator
 */
private CachingConnectionFactory buildProducerConnectionFactory() throws Exception {
    com.rabbitmq.client.ConnectionFactory rabbitConnectionFactory;
    if (this.rabbitConnectionFactory instanceof CachingConnectionFactory) {
        rabbitConnectionFactory = ((CachingConnectionFactory) this.rabbitConnectionFactory)
                .getRabbitConnectionFactory();
    }
    else {
        RabbitConnectionFactoryBean factory = new RabbitConnectionFactoryBean();
        String host = this.rabbitProperties.determineHost();
        if (host != null) {
            factory.setHost(host);
        }
        factory.setPort(this.rabbitProperties.determinePort());
        String user = this.rabbitProperties.determineUsername();
        if (user != null) {
            factory.setUsername(user);
        }
        String password = this.rabbitProperties.determinePassword();
        if (password != null) {
            factory.setPassword(password);
        }
        String vHost = this.rabbitProperties.determineVirtualHost();
        if (vHost != null) {
            factory.setVirtualHost(vHost);
        }
        Duration requestedHeartbeatDuration = this.rabbitProperties.getRequestedHeartbeat();
        if (requestedHeartbeatDuration != null) {
            factory.setRequestedHeartbeat((int) requestedHeartbeatDuration.getSeconds());
        }
        RabbitProperties.Ssl ssl = this.rabbitProperties.getSsl();
        if (ssl.isEnabled()) {
            factory.setUseSSL(true);
            if (ssl.getAlgorithm() != null) {
                factory.setSslAlgorithm(ssl.getAlgorithm());
            }
            factory.setKeyStore(ssl.getKeyStore());
            factory.setKeyStorePassphrase(ssl.getKeyStorePassword());
            factory.setTrustStore(ssl.getTrustStore());
            factory.setTrustStorePassphrase(ssl.getTrustStorePassword());
        }
        Duration connectionTimeoutDuration = this.rabbitProperties.getConnectionTimeout();
        if (connectionTimeoutDuration != null) {
            factory.setConnectionTimeout((int) connectionTimeoutDuration.getSeconds());
        }
        factory.afterPropertiesSet();

        rabbitConnectionFactory = factory.getObject();
    }

    CachingConnectionFactory connectionFactory = new CachingConnectionFactory(rabbitConnectionFactory);

    RabbitServiceAutoConfiguration.configureCachingConnectionFactory(connectionFactory, this.applicationContext,
            this.rabbitProperties);

    return connectionFactory;
}
项目:spring-cloud-stream-binder-rabbit    文件:RabbitTestBinder.java   
public RabbitTestBinder(ConnectionFactory connectionFactory, RabbitProperties rabbitProperties) {
    this(connectionFactory, new RabbitMessageChannelBinder(connectionFactory, rabbitProperties,
            new RabbitExchangeQueueProvisioner(connectionFactory)));
}
项目:spring-boot-health-indicators    文件:RabbitMQManagement.java   
public RabbitMQManagement(RabbitProperties rabbitProperties, RabbitMQResilienceHealthProperties rabbitMQResilienceHealthProperties) {
  this.rabbitProperties = rabbitProperties;
  this.rabbitMQResilienceHealthProperties = rabbitMQResilienceHealthProperties;
}
项目:hawkbit    文件:AmqpTestConfiguration.java   
@Bean
RabbitMqSetupService rabbitmqSetupService(RabbitProperties properties) {
    return new RabbitMqSetupService(properties);
}