public class RabbitConnectionFactoryBean extends AbstractFactoryBean<com.rabbitmq.client.ConnectionFactory>
sslPropertiesLocation
is not null, the
default implementation loads a PKCS12
keystore and a JKS
truststore
using the supplied properties and intializes key and trust manager factories, using
algorithm SunX509
by default. These are then used to initialize an
SSLContext
using the sslAlgorithm
(default
TLSv1.1).
Override createSSLContext()
to create and/or perform further modification of
the context.
Override setUpSSL()
to take complete control over setting up SSL.
Modifier and Type | Field and Description |
---|---|
protected com.rabbitmq.client.ConnectionFactory |
connectionFactory |
logger
OBJECT_TYPE_ATTRIBUTE
Constructor and Description |
---|
RabbitConnectionFactoryBean() |
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet() |
protected KeyManager[] |
configureKeyManagers() |
protected TrustManager[] |
configureTrustManagers() |
protected com.rabbitmq.client.ConnectionFactory |
createInstance() |
protected SSLContext |
createSSLContext()
Override this method to create and/or configure the
SSLContext used
by the ConnectionFactory . |
protected String |
getKeyStore() |
protected String |
getKeyStoreAlgorithm() |
protected String |
getKeyStorePassphrase() |
protected Resource |
getKeyStoreResource() |
protected String |
getKeyStoreType()
Get the key store type - this defaults to PKCS12 if not overridden by
setSslPropertiesLocation(Resource) or setKeyStoreType(java.lang.String) . |
Class<?> |
getObjectType() |
com.rabbitmq.client.ConnectionFactory |
getRabbitConnectionFactory()
Access the connection factory to set any other properties not supported by
this factory bean.
|
protected ResourceLoader |
getResourceLoader()
Get the resource loader; used to resolve the key store and trust store
Resource s
to input streams. |
protected SecureRandom |
getSecureRandom() |
protected String |
getSslAlgorithm() |
protected Resource |
getSslPropertiesLocation() |
protected String |
getTrustStore() |
protected String |
getTrustStoreAlgorithm() |
protected String |
getTrustStorePassphrase() |
protected Resource |
getTrustStoreResource() |
protected String |
getTrustStoreType()
Get the trust store type - this defaults to JKS if not overridden by
setSslPropertiesLocation(Resource) or setTrustStoreType(java.lang.String) . |
boolean |
isSkipServerCertificateValidation()
Whether or not Server Side certificate has to be validated or not.
|
protected boolean |
isUseSSL() |
void |
setAutomaticRecoveryEnabled(boolean automaticRecoveryEnabled)
Set to true to enable amqp-client automatic recovery.
|
void |
setChannelRpcTimeout(int channelRpcTimeout) |
void |
setClientProperties(Map<String,Object> clientProperties)
Add custom client properties.
|
void |
setConnectionTimeout(int connectionTimeout) |
void |
setCredentialsProvider(com.rabbitmq.client.impl.CredentialsProvider provider)
Set a credentials provider (e.g.
|
void |
setCredentialsRefreshService(com.rabbitmq.client.impl.CredentialsRefreshService service)
Set a refresh service.
|
void |
setEnableHostnameVerification(boolean enable)
Enable server hostname verification for TLS connections.
|
void |
setExceptionHandler(com.rabbitmq.client.ExceptionHandler exceptionHandler) |
void |
setHost(String host) |
void |
setKeyStore(String keyStore)
Set the key store resource (e.g.
|
void |
setKeyStoreAlgorithm(String keyStoreAlgorithm)
Set the algorithm used when creating the key store, default
SunX509 . |
void |
setKeyStorePassphrase(String keyStorePassphrase)
Set the key store pass phrase - overrides
the property in
setSslPropertiesLocation(Resource) . |
void |
setKeyStoreResource(Resource keyStoreResource)
Set a Resource pointing to the key store.
|
void |
setKeyStoreType(String keyStoreType)
Set the key store type - overrides
the property in
setSslPropertiesLocation(Resource) . |
void |
setMetricsCollector(com.rabbitmq.client.MetricsCollector metricsCollector) |
void |
setNioParams(com.rabbitmq.client.impl.nio.NioParams nioParams) |
void |
setPassword(String password) |
void |
setPort(int port) |
void |
setRequestedChannelMax(int requestedChannelMax) |
void |
setRequestedFrameMax(int requestedFrameMax) |
void |
setRequestedHeartbeat(int requestedHeartbeat) |
void |
setResourceLoader(ResourceLoader resourceLoader)
Set the resource loader; used to resolve the key store and trust store
Resource s
to input streams. |
void |
setSaslConfig(com.rabbitmq.client.SaslConfig saslConfig) |
void |
setSecureRandom(SecureRandom secureRandom)
Set the secure random to use when initializing the
SSLContext . |
void |
setSharedExecutor(ExecutorService executor) |
void |
setSkipServerCertificateValidation(boolean skipServerCertificateValidation)
Whether or not Server Side certificate has to be validated or not.
|
void |
setSocketConfigurator(com.rabbitmq.client.SocketConfigurator socketConfigurator) |
void |
setSocketFactory(SocketFactory factory) |
void |
setSslAlgorithm(String sslAlgorithm)
Set the algorithm to use; default TLSv1.1.
|
void |
setSslPropertiesLocation(Resource sslPropertiesLocation)
When
setUseSSL(boolean) is true, the SSL properties to use (optional). |
void |
setThreadFactory(ThreadFactory threadFactory) |
void |
setTopologyRecoveryEnabled(boolean topologyRecoveryEnabled)
Set to true to enable amqp-client topology recovery.
|
void |
setTrustStore(String trustStore)
Set the key store resource (e.g.
|
void |
setTrustStoreAlgorithm(String trustStoreAlgorithm)
Set the algorithm used when creating the trust store, default
SunX509 . |
void |
setTrustStorePassphrase(String trustStorePassphrase)
Set the trust store pass phrase - overrides
the property in
setSslPropertiesLocation(Resource) . |
void |
setTrustStoreResource(Resource trustStoreResource)
Set a Resource pointing to the trust store.
|
void |
setTrustStoreType(String trustStoreType)
Set the trust store type - overrides
the property in
setSslPropertiesLocation(Resource) . |
protected void |
setUpSSL()
Override this method to take complete control over the SSL setup.
|
void |
setUri(String uriString) |
void |
setUri(URI uri) |
void |
setUseNio(boolean useNio)
Whether or not the factory should be configured to use Java NIO.
|
void |
setUsername(String username) |
void |
setUseSSL(boolean useSSL)
Whether or not the factory should be configured to use SSL.
|
void |
setVirtualHost(String virtualHost) |
destroy, destroyInstance, getBeanFactory, getBeanTypeConverter, getEarlySingletonInterfaces, getObject, isSingleton, setBeanClassLoader, setBeanFactory, setSingleton
protected final com.rabbitmq.client.ConnectionFactory connectionFactory
public boolean isSkipServerCertificateValidation()
public void setSkipServerCertificateValidation(boolean skipServerCertificateValidation)
skipServerCertificateValidation
- Flag to override Server side certificate checks;
if set to true
TrustEverythingTrustManager
would be used.TrustEverythingTrustManager
public void setUseSSL(boolean useSSL)
useSSL
- true to use SSL.protected boolean isUseSSL()
public void setSslAlgorithm(String sslAlgorithm)
sslAlgorithm
- the algorithm.protected String getSslAlgorithm()
public void setSslPropertiesLocation(Resource sslPropertiesLocation)
setUseSSL(boolean)
is true, the SSL properties to use (optional).
Resource referencing a properties file with the following properties:
If this is provided, its properties (if present) will override the explicitly set property in this bean.
sslPropertiesLocation
- the Resource to the ssl propertiesprotected Resource getSslPropertiesLocation()
protected String getKeyStore()
public void setKeyStore(String keyStore)
setSslPropertiesLocation(Resource)
.
Ignored if setTrustStoreResource(Resource)
is called with a
resource.keyStore
- the keystore resource.protected Resource getKeyStoreResource()
public void setKeyStoreResource(Resource keyStoreResource)
keyStoreResource
- the resource.protected String getTrustStore()
public void setTrustStore(String trustStore)
setSslPropertiesLocation(Resource)
.
Ignored if setTrustStoreResource(Resource)
is called with a
resource.trustStore
- the truststore resource.protected Resource getTrustStoreResource()
public void setTrustStoreResource(Resource trustStoreResource)
trustStoreResource
- the resource.protected String getKeyStorePassphrase()
public void setKeyStorePassphrase(String keyStorePassphrase)
setSslPropertiesLocation(Resource)
.keyStorePassphrase
- the key store pass phrase.protected String getTrustStorePassphrase()
public void setTrustStorePassphrase(String trustStorePassphrase)
setSslPropertiesLocation(Resource)
.trustStorePassphrase
- the trust store pass phrase.protected String getKeyStoreType()
setSslPropertiesLocation(Resource)
or setKeyStoreType(java.lang.String)
.public void setKeyStoreType(String keyStoreType)
setSslPropertiesLocation(Resource)
.keyStoreType
- the key store type.KeyStore.getInstance(String)
protected String getTrustStoreType()
setSslPropertiesLocation(Resource)
or setTrustStoreType(java.lang.String)
.public void setTrustStoreType(String trustStoreType)
setSslPropertiesLocation(Resource)
.trustStoreType
- the trust store type.KeyStore.getInstance(String)
protected SecureRandom getSecureRandom()
public void setSecureRandom(SecureRandom secureRandom)
SSLContext
.
Defaults to null, in which case the default implementation is used.secureRandom
- the secure random.SSLContext.init(KeyManager[], TrustManager[], SecureRandom)
public void setHost(String host)
host
- the host.ConnectionFactory.setHost(java.lang.String)
public void setPort(int port)
port
- the port.ConnectionFactory.setPort(int)
public void setUsername(String username)
username
- the user name.ConnectionFactory.setUsername(java.lang.String)
public void setPassword(String password)
password
- the password.ConnectionFactory.setPassword(java.lang.String)
public void setCredentialsProvider(com.rabbitmq.client.impl.CredentialsProvider provider)
provider
- the provider.public void setCredentialsRefreshService(com.rabbitmq.client.impl.CredentialsRefreshService service)
service
- the service.public void setVirtualHost(String virtualHost)
virtualHost
- the virtual host.ConnectionFactory.setVirtualHost(java.lang.String)
public void setUri(URI uri)
uri
- the uri.ConnectionFactory.setUri(java.net.URI)
public void setUri(String uriString)
uriString
- the uri.ConnectionFactory.setUri(java.lang.String)
public void setRequestedChannelMax(int requestedChannelMax)
requestedChannelMax
- the max requested channels.ConnectionFactory.setRequestedChannelMax(int)
public void setRequestedFrameMax(int requestedFrameMax)
requestedFrameMax
- the requested max frames.ConnectionFactory.setRequestedFrameMax(int)
public void setConnectionTimeout(int connectionTimeout)
connectionTimeout
- the connection timeout.ConnectionFactory.setConnectionTimeout(int)
public void setRequestedHeartbeat(int requestedHeartbeat)
requestedHeartbeat
- the requested heartbeat.ConnectionFactory.setRequestedHeartbeat(int)
public void setClientProperties(Map<String,Object> clientProperties)
clientProperties
- the client properties.ConnectionFactory.setClientProperties(java.util.Map)
public void setSaslConfig(com.rabbitmq.client.SaslConfig saslConfig)
saslConfig
- the sasl config.ConnectionFactory.setSaslConfig(com.rabbitmq.client.SaslConfig)
public void setSocketFactory(SocketFactory factory)
factory
- the socket factory.ConnectionFactory.setSocketFactory(javax.net.SocketFactory)
public void setSocketConfigurator(com.rabbitmq.client.SocketConfigurator socketConfigurator)
socketConfigurator
- the socket configurator.ConnectionFactory.setSocketConfigurator(com.rabbitmq.client.SocketConfigurator)
public void setSharedExecutor(ExecutorService executor)
executor
- the executor serviceConnectionFactory.setSharedExecutor(java.util.concurrent.ExecutorService)
public void setThreadFactory(ThreadFactory threadFactory)
threadFactory
- the thread factory.ConnectionFactory.setThreadFactory(java.util.concurrent.ThreadFactory)
public void setExceptionHandler(com.rabbitmq.client.ExceptionHandler exceptionHandler)
exceptionHandler
- the exception handler.ConnectionFactory.setExceptionHandler(com.rabbitmq.client.ExceptionHandler)
public void setUseNio(boolean useNio)
useNio
- true to use Java NIO, false to use blocking IOConnectionFactory.useNio()
public void setNioParams(com.rabbitmq.client.impl.nio.NioParams nioParams)
nioParams
- the NIO parametersConnectionFactory.setNioParams(com.rabbitmq.client.impl.nio.NioParams)
public void setMetricsCollector(com.rabbitmq.client.MetricsCollector metricsCollector)
metricsCollector
- the metrics collector instanceConnectionFactory.setMetricsCollector(MetricsCollector)
public void setAutomaticRecoveryEnabled(boolean automaticRecoveryEnabled)
automaticRecoveryEnabled
- true to enable.public void setTopologyRecoveryEnabled(boolean topologyRecoveryEnabled)
topologyRecoveryEnabled
- true to enable.public void setChannelRpcTimeout(int channelRpcTimeout)
channelRpcTimeout
- continuation timeout for RPC calls in channelsConnectionFactory.setChannelRpcTimeout(int)
public void setEnableHostnameVerification(boolean enable)
This enables hostname verification regardless of the IO mode used (blocking or non-blocking IO).
This can be called typically after setting the SSLContext
with one of the
useSslProtocol
methods. Requires amqp-client 5.4.0 or later.
enable
- false to disable.ConnectionFactory.enableHostnameVerification()
protected String getKeyStoreAlgorithm()
public void setKeyStoreAlgorithm(String keyStoreAlgorithm)
SunX509
.keyStoreAlgorithm
- the algorithm.protected String getTrustStoreAlgorithm()
public void setTrustStoreAlgorithm(String trustStoreAlgorithm)
SunX509
.trustStoreAlgorithm
- the algorithm.protected ResourceLoader getResourceLoader()
Resource
s
to input streams.public void setResourceLoader(ResourceLoader resourceLoader)
Resource
s
to input streams.resourceLoader
- the resource loader.public com.rabbitmq.client.ConnectionFactory getRabbitConnectionFactory()
public void afterPropertiesSet()
afterPropertiesSet
in interface InitializingBean
afterPropertiesSet
in class AbstractFactoryBean<com.rabbitmq.client.ConnectionFactory>
public Class<?> getObjectType()
getObjectType
in interface FactoryBean<com.rabbitmq.client.ConnectionFactory>
getObjectType
in class AbstractFactoryBean<com.rabbitmq.client.ConnectionFactory>
protected com.rabbitmq.client.ConnectionFactory createInstance()
createInstance
in class AbstractFactoryBean<com.rabbitmq.client.ConnectionFactory>
protected void setUpSSL()
@Nullable protected KeyManager[] configureKeyManagers() throws KeyStoreException, IOException, NoSuchAlgorithmException, CertificateException, UnrecoverableKeyException
@Nullable protected TrustManager[] configureTrustManagers() throws KeyStoreException, IOException, NoSuchAlgorithmException, CertificateException
protected SSLContext createSSLContext() throws NoSuchAlgorithmException
SSLContext
used
by the ConnectionFactory
.SSLContext
.NoSuchAlgorithmException
- if the algorithm is not available.