Package com.rabbitmq.client
Class ConnectionFactoryConfigurator
- java.lang.Object
-
- com.rabbitmq.client.ConnectionFactoryConfigurator
-
public class ConnectionFactoryConfigurator extends java.lang.Object
Helper class to loadConnectionFactory
settings from a property file.The authorised keys are the constants values in this class (e.g. USERNAME). The property file/properties instance/map instance keys can have a prefix, the default being
rabbitmq.
.Property files can be loaded from the file system (the default), but also from the classpath, by using the
classpath:
prefix in the location.Client properties can be set by using the
client.properties.
prefix, e.g.client.properties.app.name
. Default client properties and custom client properties are merged. To remove a default client property, set its key to an empty value.- Since:
- 5.1.0
- See Also:
ConnectionFactory.load(String, String)
-
-
Field Summary
Fields Modifier and Type Field Description private static java.util.Map<java.lang.String,java.util.List<java.lang.String>>
ALIASES
static java.lang.String
CHANNEL_RPC_TIMEOUT
static java.lang.String
CHANNEL_SHOULD_CHECK_RPC_RESPONSE_TYPE
static java.lang.String
CLIENT_PROPERTIES_PREFIX
static java.lang.String
CONNECTION_CHANNEL_MAX
static java.lang.String
CONNECTION_FRAME_MAX
static java.lang.String
CONNECTION_HEARTBEAT
static java.lang.String
CONNECTION_RECOVERY_ENABLED
static java.lang.String
CONNECTION_RECOVERY_INTERVAL
static java.lang.String
CONNECTION_TIMEOUT
static java.lang.String
DEFAULT_PREFIX
static java.lang.String
HANDSHAKE_TIMEOUT
static java.lang.String
HOST
static java.lang.String
NIO_NB_IO_THREADS
static java.lang.String
NIO_READ_BYTE_BUFFER_SIZE
static java.lang.String
NIO_WRITE_BYTE_BUFFER_SIZE
static java.lang.String
NIO_WRITE_ENQUEUING_TIMEOUT_IN_MS
static java.lang.String
NIO_WRITE_QUEUE_CAPACITY
static java.lang.String
PASSWORD
static java.lang.String
PORT
static java.lang.String
SHUTDOWN_TIMEOUT
static java.lang.String
SSL_ALGORITHM
static java.lang.String
SSL_ENABLED
static java.lang.String
SSL_KEY_STORE
static java.lang.String
SSL_KEY_STORE_ALGORITHM
static java.lang.String
SSL_KEY_STORE_PASSWORD
static java.lang.String
SSL_KEY_STORE_TYPE
static java.lang.String
SSL_TRUST_STORE
static java.lang.String
SSL_TRUST_STORE_ALGORITHM
static java.lang.String
SSL_TRUST_STORE_PASSWORD
static java.lang.String
SSL_TRUST_STORE_TYPE
static java.lang.String
SSL_VALIDATE_SERVER_CERTIFICATE
static java.lang.String
SSL_VERIFY_HOSTNAME
static java.lang.String
TOPOLOGY_RECOVERY_ENABLED
static java.lang.String
USE_NIO
static java.lang.String
USERNAME
static java.lang.String
VIRTUAL_HOST
-
Constructor Summary
Constructors Constructor Description ConnectionFactoryConfigurator()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static javax.net.ssl.KeyManager[]
configureKeyManagers(java.lang.String keystore, java.lang.String keystorePassword, java.lang.String keystoreType, java.lang.String keystoreAlgorithm)
private static javax.net.ssl.TrustManager[]
configureTrustManagers(java.lang.String truststore, java.lang.String truststorePassword, java.lang.String truststoreType, java.lang.String truststoreAlgorithm)
static void
load(ConnectionFactory connectionFactory, java.lang.String propertyFileLocation)
static void
load(ConnectionFactory cf, java.lang.String propertyFileLocation, java.lang.String prefix)
static void
load(ConnectionFactory connectionFactory, java.util.Map<java.lang.String,java.lang.String> properties)
static void
load(ConnectionFactory cf, java.util.Map<java.lang.String,java.lang.String> properties, java.lang.String prefix)
static void
load(ConnectionFactory connectionFactory, java.util.Properties properties)
static void
load(ConnectionFactory connectionFactory, java.util.Properties properties, java.lang.String prefix)
private static java.io.InputStream
loadResource(java.lang.String location)
static java.lang.String
lookUp(java.lang.String key, java.util.Map<java.lang.String,java.lang.String> properties, java.lang.String prefix)
static java.lang.String
lookUp(java.lang.String key, java.util.Map<java.lang.String,java.lang.String> properties, java.lang.String prefix, java.lang.String defaultValue)
private static void
setUpBasicSsl(ConnectionFactory cf, boolean validateServerCertificate, boolean verifyHostname, java.lang.String sslAlgorithm)
private static void
setUpSsl(ConnectionFactory cf, java.util.Map<java.lang.String,java.lang.String> properties, java.lang.String prefix)
private static void
useDefaultTrustStore(ConnectionFactory cf, java.lang.String sslAlgorithm, boolean verifyHostname)
-
-
-
Field Detail
-
DEFAULT_PREFIX
public static final java.lang.String DEFAULT_PREFIX
- See Also:
- Constant Field Values
-
USERNAME
public static final java.lang.String USERNAME
- See Also:
- Constant Field Values
-
PASSWORD
public static final java.lang.String PASSWORD
- See Also:
- Constant Field Values
-
VIRTUAL_HOST
public static final java.lang.String VIRTUAL_HOST
- See Also:
- Constant Field Values
-
HOST
public static final java.lang.String HOST
- See Also:
- Constant Field Values
-
PORT
public static final java.lang.String PORT
- See Also:
- Constant Field Values
-
CONNECTION_CHANNEL_MAX
public static final java.lang.String CONNECTION_CHANNEL_MAX
- See Also:
- Constant Field Values
-
CONNECTION_FRAME_MAX
public static final java.lang.String CONNECTION_FRAME_MAX
- See Also:
- Constant Field Values
-
CONNECTION_HEARTBEAT
public static final java.lang.String CONNECTION_HEARTBEAT
- See Also:
- Constant Field Values
-
CONNECTION_TIMEOUT
public static final java.lang.String CONNECTION_TIMEOUT
- See Also:
- Constant Field Values
-
HANDSHAKE_TIMEOUT
public static final java.lang.String HANDSHAKE_TIMEOUT
- See Also:
- Constant Field Values
-
SHUTDOWN_TIMEOUT
public static final java.lang.String SHUTDOWN_TIMEOUT
- See Also:
- Constant Field Values
-
CLIENT_PROPERTIES_PREFIX
public static final java.lang.String CLIENT_PROPERTIES_PREFIX
- See Also:
- Constant Field Values
-
CONNECTION_RECOVERY_ENABLED
public static final java.lang.String CONNECTION_RECOVERY_ENABLED
- See Also:
- Constant Field Values
-
TOPOLOGY_RECOVERY_ENABLED
public static final java.lang.String TOPOLOGY_RECOVERY_ENABLED
- See Also:
- Constant Field Values
-
CONNECTION_RECOVERY_INTERVAL
public static final java.lang.String CONNECTION_RECOVERY_INTERVAL
- See Also:
- Constant Field Values
-
CHANNEL_RPC_TIMEOUT
public static final java.lang.String CHANNEL_RPC_TIMEOUT
- See Also:
- Constant Field Values
-
CHANNEL_SHOULD_CHECK_RPC_RESPONSE_TYPE
public static final java.lang.String CHANNEL_SHOULD_CHECK_RPC_RESPONSE_TYPE
- See Also:
- Constant Field Values
-
USE_NIO
public static final java.lang.String USE_NIO
- See Also:
- Constant Field Values
-
NIO_READ_BYTE_BUFFER_SIZE
public static final java.lang.String NIO_READ_BYTE_BUFFER_SIZE
- See Also:
- Constant Field Values
-
NIO_WRITE_BYTE_BUFFER_SIZE
public static final java.lang.String NIO_WRITE_BYTE_BUFFER_SIZE
- See Also:
- Constant Field Values
-
NIO_NB_IO_THREADS
public static final java.lang.String NIO_NB_IO_THREADS
- See Also:
- Constant Field Values
-
NIO_WRITE_ENQUEUING_TIMEOUT_IN_MS
public static final java.lang.String NIO_WRITE_ENQUEUING_TIMEOUT_IN_MS
- See Also:
- Constant Field Values
-
NIO_WRITE_QUEUE_CAPACITY
public static final java.lang.String NIO_WRITE_QUEUE_CAPACITY
- See Also:
- Constant Field Values
-
SSL_ALGORITHM
public static final java.lang.String SSL_ALGORITHM
- See Also:
- Constant Field Values
-
SSL_ENABLED
public static final java.lang.String SSL_ENABLED
- See Also:
- Constant Field Values
-
SSL_KEY_STORE
public static final java.lang.String SSL_KEY_STORE
- See Also:
- Constant Field Values
-
SSL_KEY_STORE_PASSWORD
public static final java.lang.String SSL_KEY_STORE_PASSWORD
- See Also:
- Constant Field Values
-
SSL_KEY_STORE_TYPE
public static final java.lang.String SSL_KEY_STORE_TYPE
- See Also:
- Constant Field Values
-
SSL_KEY_STORE_ALGORITHM
public static final java.lang.String SSL_KEY_STORE_ALGORITHM
- See Also:
- Constant Field Values
-
SSL_TRUST_STORE
public static final java.lang.String SSL_TRUST_STORE
- See Also:
- Constant Field Values
-
SSL_TRUST_STORE_PASSWORD
public static final java.lang.String SSL_TRUST_STORE_PASSWORD
- See Also:
- Constant Field Values
-
SSL_TRUST_STORE_TYPE
public static final java.lang.String SSL_TRUST_STORE_TYPE
- See Also:
- Constant Field Values
-
SSL_TRUST_STORE_ALGORITHM
public static final java.lang.String SSL_TRUST_STORE_ALGORITHM
- See Also:
- Constant Field Values
-
SSL_VALIDATE_SERVER_CERTIFICATE
public static final java.lang.String SSL_VALIDATE_SERVER_CERTIFICATE
- See Also:
- Constant Field Values
-
SSL_VERIFY_HOSTNAME
public static final java.lang.String SSL_VERIFY_HOSTNAME
- See Also:
- Constant Field Values
-
ALIASES
private static final java.util.Map<java.lang.String,java.util.List<java.lang.String>> ALIASES
-
-
Method Detail
-
load
public static void load(ConnectionFactory cf, java.lang.String propertyFileLocation, java.lang.String prefix) throws java.io.IOException
- Throws:
java.io.IOException
-
loadResource
private static java.io.InputStream loadResource(java.lang.String location) throws java.io.FileNotFoundException
- Throws:
java.io.FileNotFoundException
-
load
public static void load(ConnectionFactory cf, java.util.Map<java.lang.String,java.lang.String> properties, java.lang.String prefix)
-
setUpSsl
private static void setUpSsl(ConnectionFactory cf, java.util.Map<java.lang.String,java.lang.String> properties, java.lang.String prefix)
-
configureKeyManagers
private static javax.net.ssl.KeyManager[] configureKeyManagers(java.lang.String keystore, java.lang.String keystorePassword, java.lang.String keystoreType, java.lang.String keystoreAlgorithm) throws java.security.KeyStoreException, java.io.IOException, java.security.NoSuchAlgorithmException, java.security.cert.CertificateException, java.security.UnrecoverableKeyException
- Throws:
java.security.KeyStoreException
java.io.IOException
java.security.NoSuchAlgorithmException
java.security.cert.CertificateException
java.security.UnrecoverableKeyException
-
configureTrustManagers
private static javax.net.ssl.TrustManager[] configureTrustManagers(java.lang.String truststore, java.lang.String truststorePassword, java.lang.String truststoreType, java.lang.String truststoreAlgorithm) throws java.security.KeyStoreException, java.io.IOException, java.security.NoSuchAlgorithmException, java.security.cert.CertificateException
- Throws:
java.security.KeyStoreException
java.io.IOException
java.security.NoSuchAlgorithmException
java.security.cert.CertificateException
-
setUpBasicSsl
private static void setUpBasicSsl(ConnectionFactory cf, boolean validateServerCertificate, boolean verifyHostname, java.lang.String sslAlgorithm) throws java.security.KeyManagementException, java.security.NoSuchAlgorithmException, java.security.KeyStoreException
- Throws:
java.security.KeyManagementException
java.security.NoSuchAlgorithmException
java.security.KeyStoreException
-
useDefaultTrustStore
private static void useDefaultTrustStore(ConnectionFactory cf, java.lang.String sslAlgorithm, boolean verifyHostname) throws java.security.NoSuchAlgorithmException, java.security.KeyStoreException, java.security.KeyManagementException
- Throws:
java.security.NoSuchAlgorithmException
java.security.KeyStoreException
java.security.KeyManagementException
-
load
public static void load(ConnectionFactory connectionFactory, java.lang.String propertyFileLocation) throws java.io.IOException
- Throws:
java.io.IOException
-
load
public static void load(ConnectionFactory connectionFactory, java.util.Properties properties)
-
load
public static void load(ConnectionFactory connectionFactory, java.util.Properties properties, java.lang.String prefix)
-
load
public static void load(ConnectionFactory connectionFactory, java.util.Map<java.lang.String,java.lang.String> properties)
-
lookUp
public static java.lang.String lookUp(java.lang.String key, java.util.Map<java.lang.String,java.lang.String> properties, java.lang.String prefix)
-
lookUp
public static java.lang.String lookUp(java.lang.String key, java.util.Map<java.lang.String,java.lang.String> properties, java.lang.String prefix, java.lang.String defaultValue)
-
-