Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.rabbitmq.client
Class ConnectionFactory

    java.lang.Object
      com.rabbitmq.client.ConnectionFactory

All Implemented Interfaces:
  java.lang.Cloneable

    public class ConnectionFactory

extends java.lang.Object
implements java.lang.Cloneable

Convenience "factory" class to facilitate opening a `Connection` to an AMQP broker.

Field Summary
`static int` | `DEFAULT_AMQP_OVER_SSL_PORT` The default ssl port
`static int` | `DEFAULT_AMQP_PORT` The default non-ssl port
`static int` | `DEFAULT_CHANNEL_MAX` Default maximum channel number; zero for unlimited
`static int` | `DEFAULT_CONNECTION_TIMEOUT` The default connection timeout; zero means wait indefinitely
`static int` | `DEFAULT_FRAME_MAX` Default maximum frame size; zero means no limit
`static int` | `DEFAULT_HEARTBEAT` Default heart-beat interval; zero means no heart-beats
`static java.lang.String` | `DEFAULT_HOST` The default host
`static int` | `DEFAULT_NUM_CONSUMER_THREADS` Deprecated.
`static java.lang.String` | `DEFAULT_PASS` Default password
`static java.lang.String` | `DEFAULT_USER` Default user name
`static java.lang.String` | `DEFAULT_VHOST` Default virtual host
`static int` | `USE_DEFAULT_PORT` 'Use the default port' port

Constructor Summary
`ConnectionFactory()`

Method Summary
`ConnectionFactory` | `clone()`
`protected void` | `configureSocket(java.net.Socket socket)` Provides a hook to insert custom configuration of the sockets used to connect to an AMQP server before they connect.
`protected FrameHandler` | `createFrameHandler(Address addr)`
`protected FrameHandler` | `createFrameHandler(java.net.Socket sock)`
`java.util.Map<java.lang.String,java.lang.Object>` | `getClientProperties()` Retrieve the currently-configured table of client properties that will be sent to the server during connection startup.
`int` | `getConnectionTimeout()` Retrieve the connection timeout.
`java.lang.String` | `getHost()`
`int` | `getNumConsumerThreads()` Deprecated.
`java.lang.String` | `getPassword()` Retrieve the password.
`int` | `getPort()`
`int` | `getRequestedChannelMax()` Retrieve the requested maximum channel number
`int` | `getRequestedFrameMax()` Retrieve the requested maximum frame size
`int` | `getRequestedHeartbeat()` Retrieve the requested heartbeat interval.
`SaslConfig` | `getSaslConfig()` Gets the sasl config to use when authenticating
`javax.net.SocketFactory` | `getSocketFactory()` Retrieve the socket factory used to make connections with.
`java.lang.String` | `getUsername()` Retrieve the user name.
`java.lang.String` | `getVirtualHost()` Retrieve the virtual host.
`boolean` | `isSSL()`
`Connection` | `newConnection()` Create a new broker connection
`Connection` | `newConnection(Address[] addrs)` Create a new broker connection
`Connection` | `newConnection(java.util.concurrent.ExecutorService executor)` Create a new broker connection
`Connection` | `newConnection(java.util.concurrent.ExecutorService executor, Address[] addrs)` Create a new broker connection
`void` | `setClientProperties(java.util.Map<java.lang.String,java.lang.Object> clientProperties)` Replace the table of client properties that will be sent to the server during subsequent connection startups.
`void` | `setConnectionTimeout(int connectionTimeout)` Set the connection timeout.
`void` | `setHost(java.lang.String host)`
`void` | `setNumConsumerThreads(int numConsumerThreads)` Deprecated.
`void` | `setPassword(java.lang.String password)` Set the password.
`void` | `setPort(int port)` Set the target port.
`void` | `setRequestedChannelMax(int requestedChannelMax)` Set the requested maximum channel number
`void` | `setRequestedFrameMax(int requestedFrameMax)` Set the requested maximum frame size
`void` | `setRequestedHeartbeat(int requestedHeartbeat)` Set the requested heartbeat.
`void` | `setSaslConfig(SaslConfig saslConfig)` Sets the sasl config to use when authenticating
`void` | `setSocketFactory(javax.net.SocketFactory factory)` Set the socket factory used to make connections with.
`void` | `setUri(java.lang.String uriString)` Convenience method for setting the fields in an AMQP URI: host, port, username, password and virtual host.
`void` | `setUri(java.net.URI uri)` Convenience method for setting the fields in an AMQP URI: host, port, username, password and virtual host.
`void` | `setUsername(java.lang.String username)` Set the user name.
`void` | `setVirtualHost(java.lang.String virtualHost)` Set the virtual host.
`void` | `useSslProtocol()` Convenience method for setting up a SSL socket factory, using the DEFAULT_SSL_PROTOCOL and a trusting TrustManager.
`void` | `useSslProtocol(javax.net.ssl.SSLContext context)` Convenience method for setting up an SSL socket factory.
`void` | `useSslProtocol(java.lang.String protocol)` Convenience method for setting up a SSL socket factory, using the supplied protocol and a very trusting TrustManager.
`void` | `useSslProtocol(java.lang.String protocol, javax.net.ssl.TrustManager trustManager)` Convenience method for setting up an SSL socket factory.

Methods inherited from class java.lang.Object
`equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### DEFAULT_NUM_CONSUMER_THREADS

    @Deprecated
    public static final int DEFAULT_NUM_CONSUMER_THREADS

  Deprecated.
  Default Executor threads

  See Also:
    Constant Field Values

### DEFAULT_USER

    public static final java.lang.String DEFAULT_USER

  Default user name

  See Also:
    Constant Field Values

### DEFAULT_PASS

    public static final java.lang.String DEFAULT_PASS

  Default password

  See Also:
    Constant Field Values

### DEFAULT_VHOST

    public static final java.lang.String DEFAULT_VHOST

  Default virtual host

  See Also:
    Constant Field Values

### DEFAULT_CHANNEL_MAX

    public static final int DEFAULT_CHANNEL_MAX

  Default maximum channel number; zero for unlimited

  See Also:
    Constant Field Values

### DEFAULT_FRAME_MAX

    public static final int DEFAULT_FRAME_MAX

  Default maximum frame size; zero means no limit

  See Also:
    Constant Field Values

### DEFAULT_HEARTBEAT

    public static final int DEFAULT_HEARTBEAT

  Default heart-beat interval; zero means no heart-beats

  See Also:
    Constant Field Values

### DEFAULT_HOST

    public static final java.lang.String DEFAULT_HOST

  The default host

  See Also:
    Constant Field Values

### USE_DEFAULT_PORT

    public static final int USE_DEFAULT_PORT

  'Use the default port' port

  See Also:
    Constant Field Values

### DEFAULT_AMQP_PORT

    public static final int DEFAULT_AMQP_PORT

  The default non-ssl port

  See Also:
    Constant Field Values

### DEFAULT_AMQP_OVER_SSL_PORT

    public static final int DEFAULT_AMQP_OVER_SSL_PORT

  The default ssl port

  See Also:
    Constant Field Values

### DEFAULT_CONNECTION_TIMEOUT

    public static final int DEFAULT_CONNECTION_TIMEOUT

  The default connection timeout; zero means wait indefinitely

  See Also:
    Constant Field Values

Constructor Detail

### ConnectionFactory

    public ConnectionFactory()

Method Detail

### getNumConsumerThreads

    @Deprecated
    public int getNumConsumerThreads()

  Deprecated.

  Returns:
    number of consumer threads in default `ExecutorService`

### setNumConsumerThreads

    @Deprecated
    public void setNumConsumerThreads(int numConsumerThreads)

  Deprecated.

  Parameters:
    `numConsumerThreads` - threads in created private executor service

### getHost

    public java.lang.String getHost()

  Returns:
    the default host to use for connections

### setHost

    public void setHost(java.lang.String host)

  Parameters:
    `host` - the default host to use for connections

### getPort

    public int getPort()

  Returns:
    the default port to use for connections

### setPort

    public void setPort(int port)

  Set the target port.

  Parameters:
    `port` - the default port to use for connections

### getUsername

    public java.lang.String getUsername()

  Retrieve the user name.

  Returns:
    the AMQP user name to use when connecting to the broker

### setUsername

    public void setUsername(java.lang.String username)

  Set the user name.

  Parameters:
    `username` - the AMQP user name to use when connecting to the broker

### getPassword

    public java.lang.String getPassword()

  Retrieve the password.

  Returns:
    the password to use when connecting to the broker

### setPassword

    public void setPassword(java.lang.String password)

  Set the password.

  Parameters:
    `password` - the password to use when connecting to the broker

### getVirtualHost

    public java.lang.String getVirtualHost()

  Retrieve the virtual host.

  Returns:
    the virtual host to use when connecting to the broker

### setVirtualHost

    public void setVirtualHost(java.lang.String virtualHost)

  Set the virtual host.

  Parameters:
    `virtualHost` - the virtual host to use when connecting to the broker

### setUri

    public void setUri(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`

### setUri

    public void setUri(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`

### getRequestedChannelMax

    public int getRequestedChannelMax()

  Retrieve the requested maximum channel number

  Returns:
    the initially requested maximum channel number; zero for unlimited

### setRequestedChannelMax

    public void setRequestedChannelMax(int requestedChannelMax)

  Set the requested maximum channel number

  Parameters:
    `requestedChannelMax` - initially requested maximum channel number; zero for unlimited

### getRequestedFrameMax

    public int getRequestedFrameMax()

  Retrieve the requested maximum frame size

  Returns:
    the initially requested maximum frame size, in octets; zero for unlimited

### setRequestedFrameMax

    public void setRequestedFrameMax(int requestedFrameMax)

  Set the requested maximum frame size

  Parameters:
    `requestedFrameMax` - initially requested maximum frame size, in octets; zero for unlimited

### getRequestedHeartbeat

    public int getRequestedHeartbeat()

  Retrieve the requested heartbeat interval.

  Returns:
    the initially requested heartbeat interval, in seconds; zero for none

### setConnectionTimeout

    public void setConnectionTimeout(int connectionTimeout)

  Set the connection timeout.

  Parameters:
    `connectionTimeout` - connection establishment timeout in milliseconds; zero for infinite

### getConnectionTimeout

    public int getConnectionTimeout()

  Retrieve the connection timeout.

  Returns:
    the connection timeout, in milliseconds; zero for infinite

### setRequestedHeartbeat

    public void setRequestedHeartbeat(int requestedHeartbeat)

  Set the requested heartbeat.

  Parameters:
    `requestedHeartbeat` - the initially requested heartbeat interval, in seconds; zero for none

### getClientProperties

    public java.util.Map<java.lang.String,java.lang.Object> getClientProperties()

  Retrieve the currently-configured table of client properties that will be sent to the server during connection startup. Clients may add, delete, and alter keys in this table. Such changes will take effect when the next new connection is started using this factory.

  Returns:
    the map of client properties
  See Also:
    `setClientProperties(java.util.Map)`

### setClientProperties

    public void setClientProperties(java.util.Map<java.lang.String,java.lang.Object> clientProperties)

  Replace the table of client properties that will be sent to the server during subsequent connection startups.

  Parameters:
    `clientProperties` - the map of extra client properties
  See Also:
    `getClientProperties()`

### getSaslConfig

    public SaslConfig getSaslConfig()

  Gets the sasl config to use when authenticating

  Returns:
    the sasl config
  See Also:
    `SaslConfig`

### setSaslConfig

    public void setSaslConfig(SaslConfig saslConfig)

  Sets the sasl config to use when authenticating

  Parameters:
    `saslConfig` -
  See Also:
    `SaslConfig`

### getSocketFactory

    public javax.net.SocketFactory getSocketFactory()

  Retrieve the socket factory used to make connections with.

### setSocketFactory

    public void setSocketFactory(javax.net.SocketFactory factory)

  Set the socket factory used to make connections with. Can be used to enable SSL connections by passing in a javax.net.ssl.SSLSocketFactory instance.

  See Also:
    `useSslProtocol()`

### isSSL

    public boolean isSSL()

### useSslProtocol

    public void useSslProtocol()
                        throws java.security.NoSuchAlgorithmException,
                               java.security.KeyManagementException

  Convenience method for setting up a SSL socket factory, using the DEFAULT_SSL_PROTOCOL and a trusting TrustManager.

  Throws:
    `java.security.NoSuchAlgorithmException`
    `java.security.KeyManagementException`

### useSslProtocol

    public void useSslProtocol(java.lang.String protocol)
                        throws java.security.NoSuchAlgorithmException,
                               java.security.KeyManagementException

  Convenience method for setting up a SSL socket factory, using the supplied protocol and a very trusting TrustManager.

  Throws:
    `java.security.NoSuchAlgorithmException`
    `java.security.KeyManagementException`

### useSslProtocol

    public void useSslProtocol(java.lang.String protocol,
                               javax.net.ssl.TrustManager trustManager)
                        throws java.security.NoSuchAlgorithmException,
                               java.security.KeyManagementException

  Convenience method for setting up an SSL socket factory. Pass in the SSL protocol to use, e.g. "TLS" or "SSLv3".

  Parameters:
    `protocol` - SSL protocol to use.
  Throws:
    `java.security.NoSuchAlgorithmException`
    `java.security.KeyManagementException`

### useSslProtocol

    public void useSslProtocol(javax.net.ssl.SSLContext context)

  Convenience method for setting up an SSL socket factory. Pass in an initialized SSLContext.

  Parameters:
    `context` - An initialized SSLContext

### createFrameHandler

    protected FrameHandler createFrameHandler(Address addr)
                                       throws java.io.IOException

  Throws:
    `java.io.IOException`

### createFrameHandler

    protected FrameHandler createFrameHandler(java.net.Socket sock)
                                       throws java.io.IOException

  Throws:
    `java.io.IOException`

### configureSocket

    protected void configureSocket(java.net.Socket socket)
                            throws java.io.IOException

  Provides a hook to insert custom configuration of the sockets used to connect to an AMQP server before they connect. The default behaviour of this method is to disable Nagle's algorithm to get more consistently low latency. However it may be overridden freely and there is no requirement to retain this behaviour.

  Parameters:
    `socket` - The socket that is to be used for the Connection
  Throws:
    `java.io.IOException`

### newConnection

    public Connection newConnection(Address[] addrs)
                             throws java.io.IOException

  Create a new broker connection

  Parameters:
    `addrs` - an array of known broker addresses (hostname/port pairs) to try in order
  Returns:
    an interface to the connection
  Throws:
    `java.io.IOException` - if it encounters a problem

### newConnection

    public Connection newConnection(java.util.concurrent.ExecutorService executor,
                                    Address[] addrs)
                             throws java.io.IOException

  Create a new broker connection

  Parameters:
    `executor` - thread execution service for consumers on the connection
    `addrs` - an array of known broker addresses (hostname/port pairs) to try in order
  Returns:
    an interface to the connection
  Throws:
    `java.io.IOException` - if it encounters a problem

### newConnection

    public Connection newConnection()
                             throws java.io.IOException

  Create a new broker connection

  Returns:
    an interface to the connection
  Throws:
    `java.io.IOException` - if it encounters a problem

### newConnection

    public Connection newConnection(java.util.concurrent.ExecutorService executor)
                             throws java.io.IOException

  Create a new broker connection

  Parameters:
    `executor` - thread execution service for consumers on the connection
  Returns:
    an interface to the connection
  Throws:
    `java.io.IOException` - if it encounters a problem

### clone

    public ConnectionFactory clone()

  Overrides:
    `clone` in class `java.lang.Object`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD