| Modifier and Type | Field and Description |
|---|---|
static String |
DEFAULT_HOST
Default server host.
|
static int |
DEFAULT_MAX_PENDING_BYTES
Default maximum pending/undelivered payload bytes on a subscription.
|
static int |
DEFAULT_MAX_PENDING_MSGS
Default maximum pending/undelivered messages on a subscription.
|
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.
|
| 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.
|
long |
getMaxPendingBytes()
Gets the maximum number of pending message byes for a subscription.
|
int |
getMaxPendingMsgs()
Gets the maximum number of pending messages for a subscription.
|
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 |
setMaxPendingBytes(long max)
Sets the maximum number of pending message bytes for a subscription.
|
void |
setMaxPendingMsgs(int max)
Sets the maximum number of pending messages for a subscription.
|
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 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 static final int DEFAULT_MAX_PENDING_MSGS
This property is defined as String 65536
public static final int DEFAULT_MAX_PENDING_BYTES
This property is defined as String 67108864
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 int getMaxPendingMsgs()
DEFAULT_MAX_PENDING_MSGSpublic void setMaxPendingMsgs(int max)
max - The maximum number of pending messages for a subscriptionDEFAULT_MAX_PENDING_MSGSpublic long getMaxPendingBytes()
DEFAULT_MAX_PENDING_BYTESpublic void setMaxPendingBytes(long max)
max - The maximum number of pending message bytes for a subscriptionDEFAULT_MAX_PENDING_BYTESpublic 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.URIs, 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 URIs 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 falsepublic 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 falsepublic void setSecure(boolean secure)
secure - whether to require a secure connection with the NATS serverpublic boolean isTlsDebug()
true if TLS debug is enabled, otherwise falsepublic void setTlsDebug(boolean debug)
debug - whether TLS debug output should be enabledpublic boolean isReconnectAllowed()
true if reconnection is allowed, otherwise falsepublic 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 < 0public 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.