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 port to use for AMQP connections when using SSL
|
static int |
DEFAULT_AMQP_PORT
The default port to use for AMQP connections when not using SSL
|
static int |
DEFAULT_CHANNEL_MAX
Default value for the desired maximum channel number; zero for
unlimited
|
static int |
DEFAULT_CONNECTION_TIMEOUT
The default connection timeout (wait indefinitely until connection established or error occurs)
|
static int |
DEFAULT_FRAME_MAX
Default value for the desired maximum frame size; zero for
unlimited
|
static int |
DEFAULT_HEARTBEAT
Default value for desired heartbeat interval; zero for none
|
static java.lang.String |
DEFAULT_HOST
The default host to connect to
|
static java.lang.String |
DEFAULT_PASS
Default password
|
static java.lang.String |
DEFAULT_SSL_PROTOCOL
The default SSL protocol (currently "SSLv3").
|
static java.lang.String |
DEFAULT_USER
Default user name
|
static java.lang.String |
DEFAULT_VHOST
Default virtual host
|
static int |
USE_DEFAULT_PORT
A constant that when passed as a port number causes the connection to use the default port
|
Constructor and Description |
---|
ConnectionFactory()
Instantiate a ConnectionFactory with a default set of parameters.
|
Modifier and Type | Method and Description |
---|---|
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() |
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
|
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 |
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 |
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 DEFAULT_SSL_PROTOCOL and a 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 java.lang.String DEFAULT_SSL_PROTOCOL
public ConnectionFactory()
public java.lang.String getHost()
public void setHost(java.lang.String host)
host
- the default host to use for connectionspublic 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 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 connectionTimeout)
connectionTimeout
- connection establishment timeout in milliseconds; zero for infinitepublic int getConnectionTimeout()
public void setRequestedHeartbeat(int requestedHeartbeat)
requestedHeartbeat
- the initially requested heartbeat interval, in seconds; zero for nonepublic java.util.Map<java.lang.String,java.lang.Object> getClientProperties()
setClientProperties(java.util.Map<java.lang.String, java.lang.Object>)
public void setClientProperties(java.util.Map<java.lang.String,java.lang.Object> clientProperties)
clientProperties
- the map of extra client propertiesgetClientProperties()
public SaslConfig getSaslConfig()
SaslConfig
public void setSaslConfig(SaslConfig saslConfig)
saslConfig
- SaslConfig
public javax.net.SocketFactory getSocketFactory()
public void setSocketFactory(javax.net.SocketFactory factory)
useSslProtocol()
public boolean isSSL()
public void useSslProtocol() throws java.security.NoSuchAlgorithmException, java.security.KeyManagementException
java.security.NoSuchAlgorithmException
java.security.KeyManagementException
public void useSslProtocol(java.lang.String protocol) throws java.security.NoSuchAlgorithmException, java.security.KeyManagementException
java.security.NoSuchAlgorithmException
java.security.KeyManagementException
public 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.NoSuchAlgorithmException
java.security.KeyManagementException
public void useSslProtocol(javax.net.ssl.SSLContext context)
context
- An initialized SSLContextprotected FrameHandler createFrameHandler(Address addr) throws java.io.IOException
java.io.IOException
protected FrameHandler createFrameHandler(java.net.Socket sock) throws java.io.IOException
java.io.IOException
protected void configureSocket(java.net.Socket socket) throws java.io.IOException
socket
- The socket that is to be used for the Connectionjava.io.IOException
public Connection newConnection(Address[] addrs) throws java.io.IOException
addrs
- an array of known broker addresses (hostname/port pairs) to try in orderjava.io.IOException
- if it encounters a problempublic Connection newConnection() throws java.io.IOException
java.io.IOException
- if it encounters a problempublic ConnectionFactory clone()
clone
in class java.lang.Object