Package net.jodah.lyra
Class ConnectionOptions
java.lang.Object
net.jodah.lyra.ConnectionOptions
public class ConnectionOptions
extends java.lang.Object
Connection options. Changes will not effect connections that have already been created.
-
Constructor Summary
Constructors Constructor Description ConnectionOptions()
ConnectionOptions(com.rabbitmq.client.ConnectionFactory connectionFactory)
Creates a new Options object for theconnectionFactory
. -
Method Summary
Modifier and Type Method Description ConnectionOptions
copy()
Returns a new copy of the options.com.rabbitmq.client.Address[]
getAddresses()
Returns the addresses to attempt connections to, in round-robin order.com.rabbitmq.client.ConnectionFactory
getConnectionFactory()
Returns the ConnectionFactory for the options.java.util.concurrent.ExecutorService
getConsumerExecutor()
Returns the consumer executor.java.lang.String
getName()
com.rabbitmq.client.impl.nio.NioParams
getNioParams()
Return NioParams object.ConnectionOptions
withAddresses(com.rabbitmq.client.Address... addresses)
Sets theaddresses
to attempt connections to, in round-robin order.ConnectionOptions
withAddresses(java.lang.String addresses)
Sets theaddresses
.ConnectionOptions
withClientProperties(java.util.Map<java.lang.String,java.lang.Object> clientProperties)
Sets the client properties.ConnectionOptions
withConnectionFactory(com.rabbitmq.client.ConnectionFactory connectionFactory)
Sets theconnectionFactory
.ConnectionOptions
withConnectionTimeout(Duration connectionTimeout)
Set the connection timeout, zero for infinite, for an individual connection attempt.ConnectionOptions
withConsumerExecutor(java.util.concurrent.ExecutorService executor)
Sets the executor used to handle consumer callbacks.ConnectionOptions
withHost(java.lang.String host)
Sets thehost
.ConnectionOptions
withHosts(java.lang.String... hosts)
Sets thehosts
to attempt connections to, in round-robin order.ConnectionOptions
withName(java.lang.String name)
Sets the connection name.ConnectionOptions
withNio()
Support for Java non-blocking IOConnectionOptions
withNioParams(com.rabbitmq.client.impl.nio.NioParams nioParams)
Support for Java non-blocking IOConnectionOptions
withPassword(java.lang.String password)
Sets the password.ConnectionOptions
withPort(int port)
Set the port.ConnectionOptions
withRequestedHeartbeat(Duration requestedHeartbeat)
Set the requested heartbeat, zero for none.ConnectionOptions
withSocketFactory(javax.net.SocketFactory socketFactory)
Sets the SocketFactory to create connections with.ConnectionOptions
withSsl()
Enabled SSL using SSLv3.ConnectionOptions
withSslProtocol(java.lang.String sslProtocol)
Sets thesslProtocol
to use.ConnectionOptions
withSslProtocol(java.lang.String sslProtocol, javax.net.ssl.TrustManager trustManager)
Sets thesslProtocol
andtrustManager
to use.ConnectionOptions
withSslProtocol(javax.net.ssl.SSLContext sslContext)
Sets the initializedsslContext
to use.ConnectionOptions
withUri(java.lang.String uriString)
Convenience method for setting the fields in an AMQP URI: host, port, username, password and virtual host.ConnectionOptions
withUri(java.net.URI uri)
Convenience method for setting the fields in an AMQP URI: host, port, username, password and virtual host.ConnectionOptions
withUsername(java.lang.String username)
Sets the username.ConnectionOptions
withVirtualHost(java.lang.String virtualHost)
Sets the virtual host.
-
Constructor Details
-
ConnectionOptions
public ConnectionOptions() -
ConnectionOptions
public ConnectionOptions(com.rabbitmq.client.ConnectionFactory connectionFactory)Creates a new Options object for theconnectionFactory
.- Throws:
java.lang.NullPointerException
- ifconnectionFactory
is null
-
-
Method Details
-
copy
Returns a new copy of the options. -
getAddresses
public com.rabbitmq.client.Address[] getAddresses()Returns the addresses to attempt connections to, in round-robin order. -
getConnectionFactory
public com.rabbitmq.client.ConnectionFactory getConnectionFactory()Returns the ConnectionFactory for the options. -
getConsumerExecutor
public java.util.concurrent.ExecutorService getConsumerExecutor()Returns the consumer executor.- See Also:
withConsumerExecutor(ExecutorService)
-
getName
public java.lang.String getName() -
getNioParams
public com.rabbitmq.client.impl.nio.NioParams getNioParams()Return NioParams object.- See Also:
withNioParams(NioParams)
,withNio()
-
withAddresses
Sets theaddresses
to attempt connections to, in round-robin order.- Throws:
java.lang.NullPointerException
- ifaddresses
is null
-
withAddresses
Sets theaddresses
.- Parameters:
addresses
- formatted as "host1[:port],host2[:port]", etc.- Throws:
java.lang.NullPointerException
- ifaddresses
is null
-
withClientProperties
public ConnectionOptions withClientProperties(java.util.Map<java.lang.String,java.lang.Object> clientProperties)Sets the client properties.- Throws:
java.lang.NullPointerException
- ifclientProperties
is null
-
withConnectionFactory
public ConnectionOptions withConnectionFactory(com.rabbitmq.client.ConnectionFactory connectionFactory)Sets theconnectionFactory
.- Throws:
java.lang.NullPointerException
- ifconnectionFactory
is null
-
withConnectionTimeout
Set the connection timeout, zero for infinite, for an individual connection attempt.- Throws:
java.lang.NullPointerException
- ifconnectionTimeout
is null
-
withConsumerExecutor
Sets the executor used to handle consumer callbacks. Theexecutor
will not be shutdown when a connection is closed.- Throws:
java.lang.NullPointerException
- ifexecutor
is null
-
withHost
Sets thehost
.- Throws:
java.lang.NullPointerException
- ifhost
is null
-
withHosts
Sets thehosts
to attempt connections to, in round-robin order.- Throws:
java.lang.NullPointerException
- ifhosts
is null
-
withName
Sets the connection name. Used for logging and consumer thread naming.- Throws:
java.lang.NullPointerException
- ifname
is null
-
withPassword
Sets the password. -
withPort
Set the port. -
withRequestedHeartbeat
Set the requested heartbeat, zero for none.- Throws:
java.lang.NullPointerException
- ifrequestedHeartbeat
is null
-
withSocketFactory
Sets the SocketFactory to create connections with.- Throws:
java.lang.NullPointerException
- ifhosts
is null
-
withSsl
public ConnectionOptions withSsl() throws java.security.NoSuchAlgorithmException, java.security.KeyManagementExceptionEnabled SSL using SSLv3.- Throws:
java.security.NoSuchAlgorithmException
java.security.KeyManagementException
-
withSslProtocol
Sets the initializedsslContext
to use.- Throws:
java.lang.NullPointerException
- ifsslContext
is null
-
withSslProtocol
public ConnectionOptions withSslProtocol(java.lang.String sslProtocol) throws java.security.NoSuchAlgorithmException, java.security.KeyManagementExceptionSets thesslProtocol
to use.- Throws:
java.lang.NullPointerException
- ifsslProtocol
is nulljava.security.NoSuchAlgorithmException
java.security.KeyManagementException
-
withSslProtocol
public ConnectionOptions withSslProtocol(java.lang.String sslProtocol, javax.net.ssl.TrustManager trustManager) throws java.security.NoSuchAlgorithmException, java.security.KeyManagementExceptionSets thesslProtocol
andtrustManager
to use.- Throws:
java.lang.NullPointerException
- ifsslProtocol
ortrustManager
are nulljava.security.NoSuchAlgorithmException
java.security.KeyManagementException
-
withUsername
Sets the username.- Throws:
java.lang.NullPointerException
- ifusername
is null
-
withVirtualHost
Sets the virtual host.- Throws:
java.lang.NullPointerException
- ifvirtualHost
is null
-
withUri
public ConnectionOptions withUri(java.net.URI uri) throws java.net.URISyntaxException, java.security.NoSuchAlgorithmException, java.security.KeyManagementExceptionConvenience method for setting the fields in an AMQP URI: host, port, username, password and virtual host. If any part of the URI is ommited, the ConnectionFactory's corresponding variable is left unchanged.- Parameters:
uri
- is the AMQP URI containing the data- Throws:
java.net.URISyntaxException
java.security.NoSuchAlgorithmException
java.security.KeyManagementException
-
withUri
public ConnectionOptions withUri(java.lang.String uriString) throws java.net.URISyntaxException, java.security.NoSuchAlgorithmException, java.security.KeyManagementExceptionConvenience method for setting the fields in an AMQP URI: host, port, username, password and virtual host. If any part of the URI is ommited, the ConnectionFactory's corresponding variable is left unchanged. Note that not all valid AMQP URIs are accepted; in particular, the hostname must be given if the port, username or password are given, and escapes in the hostname are not permitted.- Parameters:
uriString
- is the AMQP URI containing the data- Throws:
java.net.URISyntaxException
java.security.NoSuchAlgorithmException
java.security.KeyManagementException
-
withNio
Support for Java non-blocking IO -
withNioParams
Support for Java non-blocking IO- Parameters:
nioParams
- The NIO mode can be configured through the NioParams class
-