public class Options
extends java.lang.Object
Builder
.
This class, and the builder associated with it, is basically a long list of parameters. The documentation attempts
to clarify the value of each parameter in place on the builder and here, but it may be easier to read the documentation
starting with the Builder
, since it has a simple list of methods that configure the connection.Modifier and Type | Class and Description |
---|---|
static class |
Options.Builder
Options are created using a Builder.
|
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_BUFFER_SIZE
Default size for buffers in the connection, not as available as other settings,
this is primarily changed for testing,
getBufferSize() . |
static java.time.Duration |
DEFAULT_CONNECTION_TIMEOUT
Default connection timeout, see
getConnectionTimeout() . |
static java.lang.String |
DEFAULT_DATA_PORT_TYPE
Default dataport class, which will use a TCP socket,
getDataPortType() . |
static int |
DEFAULT_MAX_CONTROL_LINE
The default length, 1024 bytes, the client will allow in an
outgoing protocol control line,
getMaxControlLine() . |
static int |
DEFAULT_MAX_PINGS_OUT
Default maximum number of pings have not received a response allowed by the
client,
getMaxPingsOut() . |
static int |
DEFAULT_MAX_RECONNECT
Default maximum number of reconnect attempts, see
getMaxReconnect() . |
static java.time.Duration |
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,
getReconnectBufferSize() . |
static java.time.Duration |
DEFAULT_RECONNECT_WAIT
Default wait time before attempting reconnection to the same server, see
getReconnectWait() . |
static java.time.Duration |
DEFAULT_REQUEST_CLEANUP_INTERVAL
Default interval to clean up cancelled/timed out requests.
|
static java.lang.String |
DEFAULT_SSL_PROTOCOL
Default SSL protocol used to create an SSLContext if the
secure property is used. |
static java.lang.String |
DEFAULT_URL
Default server URL.
|
static java.lang.String |
PROP_CLEANUP_INTERVAL
Property used to configure a builder from a Properties object.
|
static java.lang.String |
PROP_CONNECTION_CB
Property used to configure a builder from a Properties object.
|
static java.lang.String |
PROP_CONNECTION_NAME
Property used to configure a builder from a Properties object.
|
static java.lang.String |
PROP_CONNECTION_TIMEOUT
Property used to configure a builder from a Properties object.
|
static java.lang.String |
PROP_DATA_PORT_TYPE
Property used to configure a builder from a Properties object.
|
static java.lang.String |
PROP_ERROR_LISTENER
Property used to configure a builder from a Properties object.
|
static java.lang.String |
PROP_MAX_CONTROL_LINE
Property used to configure a builder from a Properties object.
|
static java.lang.String |
PROP_MAX_PINGS
Property used to configure a builder from a Properties object.
|
static java.lang.String |
PROP_MAX_RECONNECT
Property used to configure a builder from a Properties object.
|
static java.lang.String |
PROP_NO_ECHO
Property used to configure a builder from a Properties object.
|
static java.lang.String |
PROP_NORANDOMIZE
Property used to configure a builder from a Properties object.
|
static java.lang.String |
PROP_OPENTLS
Property used to configure a builder from a Properties object.
|
static java.lang.String |
PROP_PASSWORD
Property used to configure a builder from a Properties object.
|
static java.lang.String |
PROP_PEDANTIC
Property used to configure a builder from a Properties object.
|
static java.lang.String |
PROP_PING_INTERVAL
Property used to configure a builder from a Properties object.
|
static java.lang.String |
PROP_RECONNECT_BUF_SIZE
Property used to configure a builder from a Properties object.
|
static java.lang.String |
PROP_RECONNECT_WAIT
Property used to configure a builder from a Properties object.
|
static java.lang.String |
PROP_SECURE
Property used to configure a builder from a Properties object.
|
static java.lang.String |
PROP_SERVERS
Property used to configure a builder from a Properties object.
|
static java.lang.String |
PROP_TOKEN
Property used to configure a builder from a Properties object.
|
static java.lang.String |
PROP_URL
Property used to configure a builder from a Properties object.
|
static java.lang.String |
PROP_USE_OLD_REQUEST_STYLE
Property used to configure a builder from a Properties object.
|
static java.lang.String |
PROP_USERNAME
Property used to configure a builder from a Properties object.
|
static java.lang.String |
PROP_UTF8_SUBJECTS
This property is used to enable support for UTF8 subjects.
|
static java.lang.String |
PROP_VERBOSE
Property used to configure a builder from a Properties object.
|
Modifier and Type | Method and Description |
---|---|
io.nats.client.impl.DataPort |
buildDataPort() |
java.lang.String |
buildProtocolConnectOptionsString(java.lang.String serverURI,
boolean includeAuth,
byte[] nonce)
Create the options string sent with a connect message.
|
AuthHandler |
getAuthHandler() |
int |
getBufferSize() |
ConnectionListener |
getConnectionListener() |
java.lang.String |
getConnectionName() |
java.time.Duration |
getConnectionTimeout() |
java.lang.String |
getDataPortType() |
ErrorListener |
getErrorListener() |
int |
getMaxControlLine() |
int |
getMaxPingsOut() |
int |
getMaxReconnect() |
java.lang.String |
getPassword() |
java.time.Duration |
getPingInterval() |
long |
getReconnectBufferSize() |
java.time.Duration |
getReconnectWait() |
java.time.Duration |
getRequestCleanupInterval() |
java.util.Collection<java.net.URI> |
getServers() |
javax.net.ssl.SSLContext |
getSslContext() |
java.lang.String |
getToken() |
java.lang.String |
getUsername() |
boolean |
isNoEcho() |
boolean |
isNoRandomize() |
boolean |
isOldRequestStyle() |
boolean |
isPedantic() |
boolean |
isTLSRequired() |
boolean |
isTrackAdvancedStats() |
boolean |
isVerbose() |
boolean |
supportUTF8Subjects() |
public static final java.lang.String DEFAULT_URL
This property is defined as "nats://localhost:4222"
public static final int DEFAULT_PORT
This property is defined as 4222
public static final int DEFAULT_MAX_RECONNECT
getMaxReconnect()
.
This property is defined as 60
public static final java.time.Duration DEFAULT_RECONNECT_WAIT
getReconnectWait()
.
This property is defined as 2 seconds.
public static final java.time.Duration DEFAULT_CONNECTION_TIMEOUT
getConnectionTimeout()
.
This property is defined as 2 seconds.}
public static final java.time.Duration DEFAULT_PING_INTERVAL
getPingInterval()
.
A value of <=0
means disabled.
This property is defined as 2 minutes.
public static final java.time.Duration DEFAULT_REQUEST_CLEANUP_INTERVAL
getRequestCleanupInterval()
.
This property is defined as 5 seconds.
public static final int DEFAULT_MAX_PINGS_OUT
getMaxPingsOut()
.
This property is defined as 2
public static final java.lang.String DEFAULT_SSL_PROTOCOL
secure property
is used.
This property is defined as "TLSv1.2"
public static final int DEFAULT_RECONNECT_BUF_SIZE
getReconnectBufferSize()
.
This property is defined as 8388608 bytes, 8 * 1024 * 1024.
public static final int DEFAULT_MAX_CONTROL_LINE
getMaxControlLine()
.
This value is configurable on the server, and should be set here to match.
public static final java.lang.String DEFAULT_DATA_PORT_TYPE
getDataPortType()
.
This option is currently provided only for testing, and experimentation, the default should be used in almost all cases.
public static final int DEFAULT_BUFFER_SIZE
getBufferSize()
.public static final java.lang.String PROP_CONNECTION_CB
connectionListener
.public static final java.lang.String PROP_DATA_PORT_TYPE
dataPortType
.public static final java.lang.String PROP_ERROR_LISTENER
errorListener
.public static final java.lang.String PROP_MAX_PINGS
maxPingsOut
.public static final java.lang.String PROP_PING_INTERVAL
pingInterval
.public static final java.lang.String PROP_CLEANUP_INTERVAL
requestCleanupInterval
.public static final java.lang.String PROP_CONNECTION_TIMEOUT
connectionTimeout
.public static final java.lang.String PROP_RECONNECT_BUF_SIZE
reconnectBufferSize
.public static final java.lang.String PROP_RECONNECT_WAIT
reconnectWait
.public static final java.lang.String PROP_MAX_RECONNECT
maxReconnects
.public static final java.lang.String PROP_PEDANTIC
pedantic
.public static final java.lang.String PROP_VERBOSE
verbose
.public static final java.lang.String PROP_NO_ECHO
noEcho
.public static final java.lang.String PROP_CONNECTION_NAME
connectionName
.public static final java.lang.String PROP_NORANDOMIZE
noRandomize
.public static final java.lang.String PROP_SERVERS
servers
. The value can be a comma-separated list of server URLs.public static final java.lang.String PROP_PASSWORD
userInfo
.public static final java.lang.String PROP_USERNAME
userInfo
.public static final java.lang.String PROP_TOKEN
token
.public static final java.lang.String PROP_URL
server
.public static final java.lang.String PROP_SECURE
sslContext
.
This property is a boolean flag, but it tells the options parser to use the
default SSL context. Set the default context before creating the options.public static final java.lang.String PROP_OPENTLS
sslContext
.
This property is a boolean flag, but it tells the options parser to use the
an SSL context that takes any server TLS certificate and does not provide
its own. The server must have tls_verify turned OFF for this option to work.public static final java.lang.String PROP_USE_OLD_REQUEST_STYLE
oldRequestStyle
.public static final java.lang.String PROP_MAX_CONTROL_LINE
maxControlLine
.public static final java.lang.String PROP_UTF8_SUBJECTS
supportUTF8Subjcts()
public ErrorListener getErrorListener()
errorListener()
in the builder docpublic ConnectionListener getConnectionListener()
connectionListener()
in the builder docpublic AuthHandler getAuthHandler()
authHandler()
in the builder docpublic java.lang.String getDataPortType()
dataPortType()
in the builder docpublic io.nats.client.impl.DataPort buildDataPort()
public java.util.Collection<java.net.URI> getServers()
servers()
in the builder docpublic boolean isNoRandomize()
noRandomize()
in the builder docpublic boolean supportUTF8Subjects()
supportUTF8Subjects()
in the builder doc.public java.lang.String getConnectionName()
connectionName()
in the builder docpublic boolean isVerbose()
verbose()
in the builder docpublic boolean isNoEcho()
noEcho()
in the builder docpublic boolean isPedantic()
pedantic()
in the builder docpublic boolean isTrackAdvancedStats()
turnOnAdvancedStats()
in the builder docpublic int getMaxControlLine()
maxControlLine()
in the builder docpublic boolean isTLSRequired()
secure()
in the builder docpublic javax.net.ssl.SSLContext getSslContext()
secure()
in the builder docpublic int getMaxReconnect()
maxReconnects()
in the builder docpublic java.time.Duration getReconnectWait()
reconnectWait()
in the builder docpublic java.time.Duration getConnectionTimeout()
connectionTimeout()
in the builder docpublic java.time.Duration getPingInterval()
pingInterval()
in the builder docpublic java.time.Duration getRequestCleanupInterval()
requestCleanupInterval()
in the builder docpublic int getMaxPingsOut()
maxPingsOut()
in the builder docpublic long getReconnectBufferSize()
reconnectBufferSize()
in the builder docpublic int getBufferSize()
bufferSize()
in the builder docpublic java.lang.String getUsername()
userInfo()
in the builder docpublic java.lang.String getPassword()
userInfo()
in the builder docpublic java.lang.String getToken()
token()
in the builder docpublic boolean isOldRequestStyle()
oldStyleRequest()
in the builder docpublic java.lang.String buildProtocolConnectOptionsString(java.lang.String serverURI, boolean includeAuth, byte[] nonce)
serverURI
- the current server uriincludeAuth
- tells the options to build a connection string that includes auth informationnonce
- if the client is supposed to sign the nonce for authentication