Class ConnectionFactoryConfigurator


  • public class ConnectionFactoryConfigurator
    extends java.lang.Object
    Helper class to load ConnectionFactory 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 Detail

      • 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
      • 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_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_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
    • Constructor Detail

      • ConnectionFactoryConfigurator

        public ConnectionFactoryConfigurator()
    • 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)