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 Details

    • ConnectionOptions

      public ConnectionOptions()
    • ConnectionOptions

      public ConnectionOptions​(com.rabbitmq.client.ConnectionFactory connectionFactory)
      Creates a new Options object for the connectionFactory.
      Throws:
      java.lang.NullPointerException - if connectionFactory is null
  • Method Details

    • copy

      public ConnectionOptions 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.
      See Also:
      withAddresses(Address...), withAddresses(String), withHost(String), withHosts(String...)
    • 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

      public ConnectionOptions withAddresses​(com.rabbitmq.client.Address... addresses)
      Sets the addresses to attempt connections to, in round-robin order.
      Throws:
      java.lang.NullPointerException - if addresses is null
    • withAddresses

      public ConnectionOptions withAddresses​(java.lang.String addresses)
      Sets the addresses.
      Parameters:
      addresses - formatted as "host1[:port],host2[:port]", etc.
      Throws:
      java.lang.NullPointerException - if addresses is null
    • withClientProperties

      public ConnectionOptions withClientProperties​(java.util.Map<java.lang.String,​java.lang.Object> clientProperties)
      Sets the client properties.
      Throws:
      java.lang.NullPointerException - if clientProperties is null
    • withConnectionFactory

      public ConnectionOptions withConnectionFactory​(com.rabbitmq.client.ConnectionFactory connectionFactory)
      Sets the connectionFactory.
      Throws:
      java.lang.NullPointerException - if connectionFactory is null
    • withConnectionTimeout

      public ConnectionOptions withConnectionTimeout​(Duration connectionTimeout)
      Set the connection timeout, zero for infinite, for an individual connection attempt.
      Throws:
      java.lang.NullPointerException - if connectionTimeout is null
    • withConsumerExecutor

      public ConnectionOptions withConsumerExecutor​(java.util.concurrent.ExecutorService executor)
      Sets the executor used to handle consumer callbacks. The executor will not be shutdown when a connection is closed.
      Throws:
      java.lang.NullPointerException - if executor is null
    • withHost

      public ConnectionOptions withHost​(java.lang.String host)
      Sets the host.
      Throws:
      java.lang.NullPointerException - if host is null
    • withHosts

      public ConnectionOptions withHosts​(java.lang.String... hosts)
      Sets the hosts to attempt connections to, in round-robin order.
      Throws:
      java.lang.NullPointerException - if hosts is null
    • withName

      public ConnectionOptions withName​(java.lang.String name)
      Sets the connection name. Used for logging and consumer thread naming.
      Throws:
      java.lang.NullPointerException - if name is null
    • withPassword

      public ConnectionOptions withPassword​(java.lang.String password)
      Sets the password.
    • withPort

      public ConnectionOptions withPort​(int port)
      Set the port.
    • withRequestedHeartbeat

      public ConnectionOptions withRequestedHeartbeat​(Duration requestedHeartbeat)
      Set the requested heartbeat, zero for none.
      Throws:
      java.lang.NullPointerException - if requestedHeartbeat is null
    • withSocketFactory

      public ConnectionOptions withSocketFactory​(javax.net.SocketFactory socketFactory)
      Sets the SocketFactory to create connections with.
      Throws:
      java.lang.NullPointerException - if hosts is null
    • withSsl

      public ConnectionOptions withSsl() throws java.security.NoSuchAlgorithmException, java.security.KeyManagementException
      Enabled SSL using SSLv3.
      Throws:
      java.security.NoSuchAlgorithmException
      java.security.KeyManagementException
    • withSslProtocol

      public ConnectionOptions withSslProtocol​(javax.net.ssl.SSLContext sslContext)
      Sets the initialized sslContext to use.
      Throws:
      java.lang.NullPointerException - if sslContext is null
    • withSslProtocol

      public ConnectionOptions withSslProtocol​(java.lang.String sslProtocol) throws java.security.NoSuchAlgorithmException, java.security.KeyManagementException
      Sets the sslProtocol to use.
      Throws:
      java.lang.NullPointerException - if sslProtocol is null
      java.security.NoSuchAlgorithmException
      java.security.KeyManagementException
    • withSslProtocol

      public ConnectionOptions withSslProtocol​(java.lang.String sslProtocol, javax.net.ssl.TrustManager trustManager) throws java.security.NoSuchAlgorithmException, java.security.KeyManagementException
      Sets the sslProtocol and trustManager to use.
      Throws:
      java.lang.NullPointerException - if sslProtocol or trustManager are null
      java.security.NoSuchAlgorithmException
      java.security.KeyManagementException
    • withUsername

      public ConnectionOptions withUsername​(java.lang.String username)
      Sets the username.
      Throws:
      java.lang.NullPointerException - if username is null
    • withVirtualHost

      public ConnectionOptions withVirtualHost​(java.lang.String virtualHost)
      Sets the virtual host.
      Throws:
      java.lang.NullPointerException - if virtualHost is null
    • withUri

      public ConnectionOptions withUri​(java.net.URI uri) throws java.net.URISyntaxException, java.security.NoSuchAlgorithmException, java.security.KeyManagementException
      Convenience 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.KeyManagementException
      Convenience 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

      public ConnectionOptions withNio()
      Support for Java non-blocking IO
    • withNioParams

      public ConnectionOptions withNioParams​(com.rabbitmq.client.impl.nio.NioParams nioParams)
      Support for Java non-blocking IO
      Parameters:
      nioParams - The NIO mode can be configured through the NioParams class