Example usage for com.rabbitmq.client ConnectionFactory setClientProperties

List of usage examples for com.rabbitmq.client ConnectionFactory setClientProperties

Introduction

In this page you can find the example usage for com.rabbitmq.client ConnectionFactory setClientProperties.

Prototype

public void setClientProperties(Map<String, Object> clientProperties) 

Source Link

Document

Replace the table of client properties that will be sent to the server during subsequent connection startups.

Usage

From source file:com.nxttxn.vramel.components.rabbitMQ.RabbitMQEndpoint.java

License:Apache License

private ConnectionFactory getOrCreateConnectionFactory() {
    if (connectionFactory == null) {
        ConnectionFactory factory = new ConnectionFactory();
        factory.setUsername(getUsername());
        factory.setPassword(getPassword());
        factory.setVirtualHost(getVhost());
        factory.setHost(getHostname());//from  w  w w.  j  a va2 s  .co  m
        factory.setPort(getPortNumber());
        if (getClientProperties() != null) {
            factory.setClientProperties(getClientProperties());
        }
        factory.setConnectionTimeout(getConnectionTimeout());
        factory.setRequestedChannelMax(getRequestedChannelMax());
        factory.setRequestedFrameMax(getRequestedFrameMax());
        factory.setRequestedHeartbeat(getRequestedHeartbeat());
        if (getSslProtocol() != null) {
            try {
                if (getSslProtocol().equals("true")) {
                    factory.useSslProtocol();
                } else if (getTrustManager() == null) {
                    factory.useSslProtocol(getSslProtocol());
                } else {
                    factory.useSslProtocol(getSslProtocol(), getTrustManager());
                }
            } catch (NoSuchAlgorithmException | KeyManagementException e) {
                throw new IllegalArgumentException("Invalid sslProtocol " + sslProtocol, e);
            }
        }
        if (getAutomaticRecoveryEnabled() != null) {
            factory.setAutomaticRecoveryEnabled(getAutomaticRecoveryEnabled());
        }
        if (getNetworkRecoveryInterval() != null) {
            factory.setNetworkRecoveryInterval(getNetworkRecoveryInterval());
        }
        if (getTopologyRecoveryEnabled() != null) {
            factory.setTopologyRecoveryEnabled(getTopologyRecoveryEnabled());
        }
        connectionFactory = factory;
    }
    return connectionFactory;
}

From source file:ws.ament.hammock.rabbitmq.ConnectionFactoryProducer.java

License:Apache License

@Produces
@ApplicationScoped/*  w w w.  j  a v a 2s .c o  m*/
public ConnectionFactory createConnectionFactory(RabbitMQConfiguration rabbitMQConfiguration) {
    ConnectionFactory connectionFactory = new ConnectionFactory();
    connectionFactory.setAutomaticRecoveryEnabled(rabbitMQConfiguration.isAutomaticRecovery());
    connectionFactory.setClientProperties(rabbitMQConfiguration.getClientProperties());
    connectionFactory.setConnectionTimeout(rabbitMQConfiguration.getConnectionTimeout());
    connectionFactory.setExceptionHandler(rabbitMQConfiguration.getExceptionHandler());
    connectionFactory.setHandshakeTimeout(rabbitMQConfiguration.getHandshakeTimeout());
    connectionFactory.setHeartbeatExecutor(rabbitMQConfiguration.getHeartbeatExecutor());
    connectionFactory.setMetricsCollector(rabbitMQConfiguration.getMetricsCollector());
    connectionFactory.setHost(rabbitMQConfiguration.getHost());
    connectionFactory.setNetworkRecoveryInterval(rabbitMQConfiguration.getNetworkRecoveryInterval());
    if (rabbitMQConfiguration.isNio()) {
        connectionFactory.useNio();
        connectionFactory.setNioParams(rabbitMQConfiguration.getNioParams());
    }
    connectionFactory.setPassword(rabbitMQConfiguration.getPassword());
    connectionFactory.setPort(rabbitMQConfiguration.getPort());
    connectionFactory.setRequestedChannelMax(rabbitMQConfiguration.getRequestedChannelMax());
    connectionFactory.setRequestedFrameMax(rabbitMQConfiguration.getRequestedFrameMax());
    connectionFactory.setRequestedHeartbeat(rabbitMQConfiguration.getRequestedHeartbeat());
    connectionFactory.setSaslConfig(rabbitMQConfiguration.getSaslConfig());
    connectionFactory.setSharedExecutor(rabbitMQConfiguration.getSharedExecutor());
    connectionFactory.setShutdownExecutor(rabbitMQConfiguration.getShutdownExecutor());
    connectionFactory.setShutdownTimeout(rabbitMQConfiguration.getShutdownTimeout());
    connectionFactory.setSocketConfigurator(rabbitMQConfiguration.getSocketConf());
    connectionFactory.setSocketFactory(rabbitMQConfiguration.getFactory());
    connectionFactory.setThreadFactory(rabbitMQConfiguration.getThreadFactory());
    connectionFactory.setTopologyRecoveryEnabled(rabbitMQConfiguration.isTopologyRecovery());
    try {
        connectionFactory.setUri(rabbitMQConfiguration.getUri());
    } catch (Exception e) {
        throw new RuntimeException("Unable to populate URI ", e);
    }
    connectionFactory.setUsername(rabbitMQConfiguration.getUsername());
    connectionFactory.setVirtualHost(rabbitMQConfiguration.getVirtualHost());
    if (rabbitMQConfiguration.getSslContext() != null) {
        connectionFactory.useSslProtocol(rabbitMQConfiguration.getSslContext());
    }
    return connectionFactory;
}