Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_HOST
Default server host.
|
static int |
DEFAULT_MAX_PINGS_OUT
Default maximum number of pings that have not received a response.
|
static int |
DEFAULT_MAX_RECONNECT
Default maximum number of reconnect attempts.
|
static int |
DEFAULT_PING_INTERVAL
Default server ping interval.
|
static int |
DEFAULT_PORT
Default server port.
|
static int |
DEFAULT_RECONNECT_BUF_SIZE
Default of pending message buffer that is used for buffering messages that are published
during a disconnect/reconnect.
|
static int |
DEFAULT_RECONNECT_WAIT
Default wait time before attempting reconnection to the same server.
|
static int |
DEFAULT_TIMEOUT
Default connection timeout.
|
static String |
DEFAULT_URL
Default server URL.
|
static String |
PROP_CLOSED_CB
This property is defined as String "io.nats.client.callback.closed".
|
static String |
PROP_CONNECTION_NAME
This property is defined as String "io.nats.client.name".
|
static String |
PROP_CONNECTION_TIMEOUT
This property is defined as String "io.nats.client.timeout".
|
static String |
PROP_DISCONNECTED_CB
This property is defined as String "io.nats.client.callback.disconnected".
|
static String |
PROP_EXCEPTION_HANDLER
This property is defined as String "io.nats.client.callback.exception".
|
static String |
PROP_HOST
This property is defined as String "io.nats.client.host".
|
static String |
PROP_MAX_PINGS
This property is defined as String "io.nats.client.maxpings".
|
static String |
PROP_MAX_RECONNECT
This property is defined as String "io.nats.client.reconnect.max".
|
static String |
PROP_NORANDOMIZE
This property is defined as String "io.nats.client.norandomize".
|
static String |
PROP_PASSWORD
This property is defined as String "io.nats.client.password".
|
static String |
PROP_PEDANTIC
This property is defined as String "io.nats.client.pedantic".
|
static String |
PROP_PING_INTERVAL
This property is defined as String "io.nats.client.pinginterval".
|
static String |
PROP_PORT
This property is defined as String "io.nats.client.port".
|
static String |
PROP_RECONNECT_ALLOWED
This property is defined as String "io.nats.client.reconnect.allowed".
|
static String |
PROP_RECONNECT_BUF_SIZE
This property is defined as String "io.nats.client.reconnect.buffer.size".
|
static String |
PROP_RECONNECT_WAIT
This property is defined as String "io.nats.client.reconnect.wait".
|
static String |
PROP_RECONNECTED_CB
This property is defined as String "io.nats.client.callback.reconnected".
|
static String |
PROP_SECURE
This property is defined as String "io.nats.client.secure".
|
static String |
PROP_SERVERS
This property is defined as String "io.nats.client.servers".
|
static String |
PROP_TLS_DEBUG
This property is defined as String "io.nats.client.tls.debug".
|
static String |
PROP_URL
This property is defined as String "io.nats.client.url".
|
static String |
PROP_USERNAME
This property is defined as String "io.nats.client.username".
|
static String |
PROP_VERBOSE
This property is defined as String "io.nats.client.verbose".
|
Constructor and Description |
---|
ConnectionFactory()
Constructs a connection factory using default parameters.
|
ConnectionFactory(ConnectionFactory cf)
Constructs a
ConnectionFactory by copying the supplied ConnectionFactory . |
ConnectionFactory(Properties props)
Constructs a new connection factory from a
Properties object. |
ConnectionFactory(String url)
Constructs a connection factory using the supplied URL string as default.
|
ConnectionFactory(String[] servers)
Constructs a connection factory from a list of NATS server URL strings.
|
ConnectionFactory(String url,
String[] servers)
Constructs a connection factory from a list of NATS server URLs, using
url as the
primary address. |
Modifier and Type | Method and Description |
---|---|
ConnectionFactory |
clone()
.
|
Connection |
createConnection()
Creates an active connection to a NATS server
|
ClosedCallback |
getClosedCallback()
Returns the
ClosedCallback , if one is registered. |
String |
getConnectionName()
Gets the name associated with this Connection
|
int |
getConnectionTimeout()
Returns the connection timeout interval in milliseconds.
|
DisconnectedCallback |
getDisconnectedCallback()
Returns the
DisconnectedCallback , if one is registered. |
ExceptionHandler |
getExceptionHandler()
Returns the
ExceptionHandler , if one is registered. |
String |
getHost()
Gets the default server host, if set.
|
int |
getMaxPingsOut()
Returns the maximum number of outstanding server pings
|
int |
getMaxReconnect()
Gets the maximum number of reconnection attempts for this connection.
|
String |
getPassword()
Gets the default password, or
null if not set. |
long |
getPingInterval()
Gets the server ping interval in milliseconds.
|
int |
getPort()
Gets the default server port, if set.
|
long |
getReconnectBufSize()
Returns the maximum size in bytes of the pending message buffer, which is used to buffer
messages between a disconnect and subsequent reconnect.
|
ReconnectedCallback |
getReconnectedCallback()
Returns the
ReconnectedCallback , if one is registered. |
long |
getReconnectWait()
Returns the reconnect wait interval in milliseconds.
|
List<URI> |
getServers()
Gets the server list as
URI . |
SSLContext |
getSslContext()
Deprecated.
use
getSSLContext() instead.
Returns the SSLContext for this connection factory |
SSLContext |
getSSLContext()
Returns the
SSLContext for this connection factory. |
String |
getUrlString()
Returns the default server URL string, if set.
|
String |
getUsername()
Gets the default username, if set.
|
boolean |
isNoRandomize()
Indicates whether server list randomization is disabled.
|
boolean |
isPedantic()
Indicates whether strict server-side protocol checking is enabled.
|
boolean |
isReconnectAllowed()
Indicates whether reconnection is enabled.
|
boolean |
isSecure()
Indicates whether to require a secure connection with the NATS server.
|
boolean |
isTlsDebug()
Indicates whether TLS debug output should be enabled.
|
boolean |
isVerbose()
Indicates whether
verbose is set. |
void |
setClosedCallback(ClosedCallback cb)
Sets the
ClosedCallback . |
void |
setConnectionName(String connectionName)
Sets the name associated with this Connection
|
void |
setConnectionTimeout(int timeout)
Sets the connection timeout interval in milliseconds.
|
void |
setDisconnectedCallback(DisconnectedCallback cb)
Sets the
DisconnectedCallback . |
void |
setExceptionHandler(ExceptionHandler exceptionHandler)
Sets the
ExceptionHandler . |
void |
setHost(String host)
Sets the default server host.
|
void |
setMaxPingsOut(int max)
Sets the maximum number of outstanding pings (pings for which no pong has been received).
|
void |
setMaxReconnect(int max)
Sets the maximum number of reconnection attempts for this connection.
|
void |
setNoRandomize(boolean noRandomize)
Disables or enables server list randomization.
|
void |
setPassword(String password)
Sets the default password.
|
void |
setPedantic(boolean pedantic)
Sets whether strict server-side protocol checking is enabled.
|
void |
setPingInterval(long interval)
Sets the server ping interval in milliseconds.
|
void |
setPort(int port)
Sets the default server port.
|
void |
setReconnectAllowed(boolean reconnectAllowed)
Sets whether reconnection is enabled.
|
void |
setReconnectBufSize(int size)
Sets the maximum size in bytes of the pending message buffer, which is used to buffer
messages between a disconnect and subsequent reconnect.
|
void |
setReconnectedCallback(ReconnectedCallback cb)
Sets the
ReconnectedCallback . |
void |
setReconnectWait(long interval)
Sets the reconnect wait interval in milliseconds.
|
void |
setSecure(boolean secure)
Sets whether to require a secure connection with the NATS server.
|
void |
setServers(List<URI> servers)
Sets the server list from a list of
URI . |
void |
setServers(String urlString)
Sets the server list from a comma-delimited list of server addresses in a single string.
|
void |
setServers(String[] servers)
Sets the server list from a list of
String . |
void |
setSslContext(SSLContext ctx)
Deprecated.
use
setSSLContext(javax.net.ssl.SSLContext) instead.
Sets the SSLContext for this connection factory |
void |
setSSLContext(SSLContext ctx)
Sets the
SSLContext for this connection factory. |
void |
setTlsDebug(boolean debug)
Sets whether TLS debug output should be enabled.
|
void |
setUri(URI uri)
Convenience function to set host, port, username, password from a java.net.URI.
|
void |
setUrl(String url)
Sets the default server URL string.
|
void |
setUsername(String username)
Sets the default username.
|
void |
setVerbose(boolean verbose)
Sets whether
verbose is set. |
public static final String PROP_URL
public static final String PROP_HOST
public static final String PROP_PORT
public static final String PROP_USERNAME
public static final String PROP_PASSWORD
public static final String PROP_SERVERS
public static final String PROP_NORANDOMIZE
public static final String PROP_CONNECTION_NAME
public static final String PROP_VERBOSE
public static final String PROP_PEDANTIC
public static final String PROP_SECURE
public static final String PROP_TLS_DEBUG
public static final String PROP_RECONNECT_ALLOWED
public static final String PROP_MAX_RECONNECT
public static final String PROP_RECONNECT_WAIT
public static final String PROP_RECONNECT_BUF_SIZE
public static final String PROP_CONNECTION_TIMEOUT
public static final String PROP_PING_INTERVAL
public static final String PROP_MAX_PINGS
public static final String PROP_EXCEPTION_HANDLER
public static final String PROP_CLOSED_CB
public static final String PROP_DISCONNECTED_CB
public static final String PROP_RECONNECTED_CB
public static final String DEFAULT_HOST
This property is defined as String "localhost"
public static final int DEFAULT_PORT
This property is defined as int 4222
public static final String DEFAULT_URL
This property is defined as String "nats://localhost:4222"
public static final int DEFAULT_MAX_RECONNECT
This property is defined as String 60
public static final int DEFAULT_RECONNECT_WAIT
This property is defined as String 2000
public static final int DEFAULT_RECONNECT_BUF_SIZE
This property is defined as String 8388608
public static final int DEFAULT_TIMEOUT
This property is defined as String 2000
public static final int DEFAULT_PING_INTERVAL
<=0
means disabled.
This property is defined as String 120000
public static final int DEFAULT_MAX_PINGS_OUT
This property is defined as String 2
public ConnectionFactory(Properties props)
Properties
object.props
- the Properties
objectpublic ConnectionFactory()
public ConnectionFactory(String url)
url
- the default server URL to usepublic ConnectionFactory(String[] servers)
servers
- the list of cluster server URL stringspublic ConnectionFactory(String url, String[] servers)
url
as the
primary address.
If url
contains a single server address, that address will be first in the server
list, even if isNoRandomize()
is false
.
If url
is a comma-delimited list of servers, then servers
will be ignored.
url
- the default server URL to setservers
- the list of cluster server URL stringspublic ConnectionFactory(ConnectionFactory cf)
ConnectionFactory
by copying the supplied ConnectionFactory
.cf
- the ConnectionFactory
to copypublic Connection createConnection() throws IOException, TimeoutException
IOException
- if a Connection cannot be established for some reason.TimeoutException
- if the connection timeout has been exceeded.public ConnectionFactory clone()
public void setUri(URI uri)
uri
- the URI to setpublic String getUrlString()
null
if not setpublic void setUrl(String url)
If url
is a comma-delimited list, then setServers(String)
will be invoked
without setting the default server URL string.
url
- the URL to setpublic String getHost()
null
if not setpublic void setHost(String host)
host
- the host to setpublic int getPort()
-1
if not setpublic void setPort(int port)
port
- the port to setpublic String getUsername()
null
if not setpublic void setUsername(String username)
username
- the username to setpublic String getPassword()
null
if not set.public void setPassword(String password)
password
- the password to setpublic List<URI> getServers()
URI
.URI
s, or null
if not setpublic void setServers(List<URI> servers)
URI
.servers
- the servers to setpublic void setServers(String urlString)
urlString
- the servers to setpublic void setServers(String[] servers)
String
.servers
- the servers to setIllegalArgumentException
- if any of the URI
s are malformedpublic boolean isNoRandomize()
true
means that the server list will be traversed in the order in which it was
received
false
means that the server list will be randomized before it is traversed
true
if server list randomization is disabled, otherwise false
public void setNoRandomize(boolean noRandomize)
noRandomize
- the noRandomize to setpublic String getConnectionName()
public void setConnectionName(String connectionName)
connectionName
- the name to set.public boolean isVerbose()
verbose
is set.
When verbose==true
, the server will acknowledge each protocol line with
+OK or -ERR
verbose
is setpublic void setVerbose(boolean verbose)
verbose
is set.verbose
- whether or not this connection should require protocol acks from the server
(+OK/-ERR)public boolean isPedantic()
pedantic
is setpublic void setPedantic(boolean pedantic)
When pedantic==true
, strict server-side protocol checking occurs.
pedantic
- whether or not this connection should require strict server-side protocol
checkingpublic boolean isSecure()
true
if secure is required, otherwise false
public void setSecure(boolean secure)
secure
- whether to require a secure connection with the NATS serverpublic boolean isTlsDebug()
true
if TLS debug is enabled, otherwise false
public void setTlsDebug(boolean debug)
debug
- whether TLS debug output should be enabledpublic boolean isReconnectAllowed()
true
if reconnection is allowed, otherwise false
public void setReconnectAllowed(boolean reconnectAllowed)
reconnectAllowed
- whether to allow reconnectspublic int getMaxReconnect()
public void setMaxReconnect(int max)
max
- the maximum number of reconnection attemptspublic long getReconnectWait()
public void setReconnectBufSize(int size)
size
- the reconnect buffer size, in bytespublic long getReconnectBufSize()
public void setReconnectWait(long interval)
interval
- the reconnectWait to setpublic int getConnectionTimeout()
public void setConnectionTimeout(int timeout)
timeout
- the connection timeoutIllegalArgumentException
- if timeout < 0
public long getPingInterval()
public void setPingInterval(long interval)
interval
- the ping interval to set in millisecondspublic int getMaxPingsOut()
public void setMaxPingsOut(int max)
max
- the maximum number of outstanding pingspublic ClosedCallback getClosedCallback()
ClosedCallback
, if one is registered.ClosedCallback
, if one is registeredpublic void setClosedCallback(ClosedCallback cb)
ClosedCallback
.cb
- the ClosedCallback
to setpublic DisconnectedCallback getDisconnectedCallback()
DisconnectedCallback
, if one is registered.DisconnectedCallback
, if one is registeredpublic void setDisconnectedCallback(DisconnectedCallback cb)
DisconnectedCallback
.cb
- the DisconnectedCallback
to setpublic ReconnectedCallback getReconnectedCallback()
ReconnectedCallback
, if one is registered.ReconnectedCallback
, if one is registeredpublic void setReconnectedCallback(ReconnectedCallback cb)
ReconnectedCallback
.cb
- the ReconnectedCallback
to setpublic ExceptionHandler getExceptionHandler()
ExceptionHandler
, if one is registered.ExceptionHandler
, if one is registeredpublic void setExceptionHandler(ExceptionHandler exceptionHandler)
ExceptionHandler
.exceptionHandler
- the ExceptionHandler
to set for connection.@Deprecated public SSLContext getSslContext()
getSSLContext()
instead.
Returns the SSLContext
for this connection factorySSLContext
for this connection factorypublic SSLContext getSSLContext()
SSLContext
for this connection factory.SSLContext
for this connection factory@Deprecated public void setSslContext(SSLContext ctx)
setSSLContext(javax.net.ssl.SSLContext)
instead.
Sets the SSLContext
for this connection factoryctx
- the SSLContext
to setpublic void setSSLContext(SSLContext ctx)
SSLContext
for this connection factory.ctx
- the SSLContext
to setCopyright © 2015–2016 Apcera, Inc.. All rights reserved.