com.rabbitmq.client
public class ConnectionFactory extends java.lang.Object implements java.lang.Cloneable
Connection to an AMQP broker.| Modifier and Type | Field and Description |
|---|---|
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 TCP connection timeout: 60 seconds
|
static int |
DEFAULT_FRAME_MAX
Default maximum frame size;
zero means no limit
|
static int |
DEFAULT_HANDSHAKE_TIMEOUT
The default AMQP 0-9-1 connection handshake timeout.
|
static int |
DEFAULT_HEARTBEAT
Default heart-beat interval;
60 seconds
|
static java.lang.String |
DEFAULT_HOST
The default host
|
static java.lang.String |
DEFAULT_PASS
Default password
|
static int |
DEFAULT_SHUTDOWN_TIMEOUT
The default shutdown timeout;
zero means wait indefinitely
|
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 and Description |
|---|
ConnectionFactory() |
| Modifier and Type | Method and Description |
|---|---|
ConnectionFactory |
clone() |
protected FrameHandlerFactory |
createFrameHandlerFactory() |
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 TCP connection timeout.
|
ExceptionHandler |
getExceptionHandler()
Get the exception handler.
|
int |
getHandshakeTimeout()
Retrieve the AMQP 0-9-1 protocol handshake timeout.
|
java.lang.String |
getHost() |
long |
getNetworkRecoveryInterval()
Returns automatic connection recovery interval in milliseconds.
|
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
|
int |
getShutdownTimeout()
Retrieve the shutdown timeout.
|
SocketConfigurator |
getSocketConfigurator()
Get the socket configurator.
|
javax.net.SocketFactory |
getSocketFactory()
Retrieve the socket factory used to make connections with.
|
java.util.concurrent.ThreadFactory |
getThreadFactory()
Retrieve the thread factory used to instantiate new threads.
|
java.lang.String |
getUsername()
Retrieve the user name.
|
java.lang.String |
getVirtualHost()
Retrieve the virtual host.
|
boolean |
isAutomaticRecoveryEnabled()
Returns true if automatic connection recovery
is enabled, false otherwise
|
boolean |
isSSL() |
boolean |
isTopologyRecoveryEnabled()
Returns true if topology recovery is enabled, false otherwise
|
Connection |
newConnection()
Create a new broker connection.
|
Connection |
newConnection(Address[] addrs)
Create a new broker connection, picking the first available address from
the list.
|
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, picking the first available address from
the list.
|
ConnectionParams |
params(java.util.concurrent.ExecutorService executor) |
static int |
portOrDefault(int port,
boolean ssl) |
void |
setAutomaticRecoveryEnabled(boolean automaticRecovery)
Enables or disables automatic connection recovery.
|
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 timeout)
Set the TCP connection timeout.
|
void |
setExceptionHandler(ExceptionHandler exceptionHandler)
Set the exception handler to use for newly created connections.
|
void |
setHandshakeTimeout(int timeout)
Set the AMQP0-9-1 protocol handshake timeout.
|
void |
setHost(java.lang.String host) |
void |
setNetworkRecoveryInterval(int networkRecoveryInterval)
Sets connection recovery interval.
|
void |
setNetworkRecoveryInterval(long networkRecoveryInterval)
Sets connection recovery interval.
|
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 timeout.
|
void |
setSaslConfig(SaslConfig saslConfig)
Sets the sasl config to use when authenticating
|
void |
setSharedExecutor(java.util.concurrent.ExecutorService executor)
Set the executor to use by default for newly created connections.
|
void |
setShutdownTimeout(int shutdownTimeout)
Set the shutdown timeout.
|
void |
setSocketConfigurator(SocketConfigurator socketConfigurator)
Set the socket configurator.
|
void |
setSocketFactory(javax.net.SocketFactory factory)
Set the socket factory used to make connections with.
|
void |
setThreadFactory(java.util.concurrent.ThreadFactory threadFactory)
Set the thread factory used to instantiate new threads.
|
void |
setTopologyRecoveryEnabled(boolean topologyRecovery)
Enables or disables topology recovery
|
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.
|
public static final java.lang.String DEFAULT_USER
public static final java.lang.String DEFAULT_PASS
public static final java.lang.String DEFAULT_VHOST
public static final int DEFAULT_CHANNEL_MAX
public static final int DEFAULT_FRAME_MAX
public static final int DEFAULT_HEARTBEAT
public static final java.lang.String DEFAULT_HOST
public static final int USE_DEFAULT_PORT
public static final int DEFAULT_AMQP_PORT
public static final int DEFAULT_AMQP_OVER_SSL_PORT
public static final int DEFAULT_CONNECTION_TIMEOUT
public static final int DEFAULT_HANDSHAKE_TIMEOUT
public static final int DEFAULT_SHUTDOWN_TIMEOUT
public java.lang.String getHost()
public void setHost(java.lang.String host)
host - the default host to use for connectionspublic static int portOrDefault(int port,
boolean ssl)
public int getPort()
public void setPort(int port)
port - the default port to use for connectionspublic java.lang.String getUsername()
public void setUsername(java.lang.String username)
username - the AMQP user name to use when connecting to the brokerpublic java.lang.String getPassword()
public void setPassword(java.lang.String password)
password - the password to use when connecting to the brokerpublic java.lang.String getVirtualHost()
public void setVirtualHost(java.lang.String virtualHost)
virtualHost - the virtual host to use when connecting to the brokerpublic void setUri(java.net.URI uri)
throws java.net.URISyntaxException,
java.security.NoSuchAlgorithmException,
java.security.KeyManagementException
uri - is the AMQP URI containing the datajava.net.URISyntaxExceptionjava.security.NoSuchAlgorithmExceptionjava.security.KeyManagementExceptionpublic void setUri(java.lang.String uriString)
throws java.net.URISyntaxException,
java.security.NoSuchAlgorithmException,
java.security.KeyManagementException
uriString - is the AMQP URI containing the datajava.net.URISyntaxExceptionjava.security.NoSuchAlgorithmExceptionjava.security.KeyManagementExceptionpublic int getRequestedChannelMax()
public void setRequestedChannelMax(int requestedChannelMax)
requestedChannelMax - initially requested maximum channel number; zero for unlimitedpublic int getRequestedFrameMax()
public void setRequestedFrameMax(int requestedFrameMax)
requestedFrameMax - initially requested maximum frame size, in octets; zero for unlimitedpublic int getRequestedHeartbeat()
public void setConnectionTimeout(int timeout)
timeout - connection TCP establishment timeout in milliseconds; zero for infinitepublic int getConnectionTimeout()
public int getHandshakeTimeout()
public void setHandshakeTimeout(int timeout)
timeout - the AMQP0-9-1 protocol handshake timeout, in millisecondspublic void setShutdownTimeout(int shutdownTimeout)
shutdownTimeout - shutdown timeout in milliseconds; zero for infinite; default 10000public int getShutdownTimeout()
public void setRequestedHeartbeat(int requestedHeartbeat)
requestedHeartbeat - the initially requested heartbeat timeout, in seconds; zero for nonepublic java.util.Map<java.lang.String,java.lang.Object> getClientProperties()
setClientProperties(java.util.Map) public void setClientProperties(java.util.Map<java.lang.String,java.lang.Object> clientProperties)
clientProperties - the map of extra client propertiesgetClientProperties()public SaslConfig getSaslConfig()
SaslConfigpublic void setSaslConfig(SaslConfig saslConfig)
saslConfig - SaslConfigpublic javax.net.SocketFactory getSocketFactory()
public void setSocketFactory(javax.net.SocketFactory factory)
useSslProtocol()public SocketConfigurator getSocketConfigurator()
public void setSocketConfigurator(SocketConfigurator socketConfigurator)
socketConfigurator - the configurator to usepublic void setSharedExecutor(java.util.concurrent.ExecutorService executor)
executor - public java.util.concurrent.ThreadFactory getThreadFactory()
ThreadFactorypublic void setThreadFactory(java.util.concurrent.ThreadFactory threadFactory)
ThreadFactorypublic ExceptionHandler getExceptionHandler()
ExceptionHandlerpublic void setExceptionHandler(ExceptionHandler exceptionHandler)
ExceptionHandlerpublic boolean isSSL()
public void useSslProtocol()
throws java.security.NoSuchAlgorithmException,
java.security.KeyManagementException
java.security.NoSuchAlgorithmExceptionjava.security.KeyManagementExceptionpublic void useSslProtocol(java.lang.String protocol)
throws java.security.NoSuchAlgorithmException,
java.security.KeyManagementException
java.security.NoSuchAlgorithmExceptionjava.security.KeyManagementExceptionpublic void useSslProtocol(java.lang.String protocol,
javax.net.ssl.TrustManager trustManager)
throws java.security.NoSuchAlgorithmException,
java.security.KeyManagementException
protocol - SSL protocol to use.java.security.NoSuchAlgorithmExceptionjava.security.KeyManagementExceptionpublic void useSslProtocol(javax.net.ssl.SSLContext context)
context - An initialized SSLContextpublic boolean isAutomaticRecoveryEnabled()
public void setAutomaticRecoveryEnabled(boolean automaticRecovery)
automaticRecovery - if true, enables connection recoverypublic boolean isTopologyRecoveryEnabled()
public void setTopologyRecoveryEnabled(boolean topologyRecovery)
topologyRecovery - if true, enables topology recoveryprotected FrameHandlerFactory createFrameHandlerFactory() throws java.io.IOException
java.io.IOExceptionpublic Connection newConnection(Address[] addrs) throws java.io.IOException, java.util.concurrent.TimeoutException
Recoverable. Future
reconnection attempts will pick a random accessible address from the provided list.addrs - an array of known broker addresses (hostname/port pairs) to try in orderjava.io.IOException - if it encounters a problemjava.util.concurrent.TimeoutExceptionpublic Connection newConnection(java.util.concurrent.ExecutorService executor, Address[] addrs) throws java.io.IOException, java.util.concurrent.TimeoutException
Recoverable. Future
reconnection attempts will pick a random accessible address from the provided list.executor - thread execution service for consumers on the connectionaddrs - an array of known broker addresses (hostname/port pairs) to try in orderjava.io.IOException - if it encounters a problemjava.util.concurrent.TimeoutExceptionpublic ConnectionParams params(java.util.concurrent.ExecutorService executor)
public Connection newConnection() throws java.io.IOException, java.util.concurrent.TimeoutException
Recoverable. Reconnection
attempts will always use the address configured on ConnectionFactory.java.io.IOException - if it encounters a problemjava.util.concurrent.TimeoutExceptionpublic Connection newConnection(java.util.concurrent.ExecutorService executor) throws java.io.IOException, java.util.concurrent.TimeoutException
Recoverable. Reconnection
attempts will always use the address configured on ConnectionFactory.executor - thread execution service for consumers on the connectionjava.io.IOException - if it encounters a problemjava.util.concurrent.TimeoutExceptionpublic ConnectionFactory clone()
clone in class java.lang.Objectpublic long getNetworkRecoveryInterval()
public void setNetworkRecoveryInterval(int networkRecoveryInterval)
networkRecoveryInterval - how long will automatic recovery wait before attempting to reconnect, in mspublic void setNetworkRecoveryInterval(long networkRecoveryInterval)
networkRecoveryInterval - how long will automatic recovery wait before attempting to reconnect, in ms