public class StreamingConnectionFactory
extends java.lang.Object
StreamingConnectionFactory object encapsulates a set of connection configuration
options. A client uses it to create a connection to the NATS streaming data system.
This class provides some options that are mapped to the underlying NATS connection, but you can
also create a streaming connection from an existing NATS core connection. Using an existing connection
allows complete control over the core NATS options.| Constructor and Description |
|---|
StreamingConnectionFactory() |
StreamingConnectionFactory(java.lang.String clusterId,
java.lang.String clientId) |
| Modifier and Type | Method and Description |
|---|---|
StreamingConnection |
createConnection()
Creates an active connection to a NATS Streaming server.
|
java.time.Duration |
getAckTimeout()
Returns the ACK timeout.
|
java.lang.String |
getClientId()
Returns the client ID of the current NATS streaming session.
|
java.lang.String |
getClusterId()
Returns the cluster ID of the current NATS streaming session.
|
io.nats.client.ConnectionListener |
getConnectionListener() |
java.time.Duration |
getConnectTimeout()
Returns the connect timeout interval in milliseconds.
|
java.lang.String |
getDiscoverPrefix()
Returns the currently configured discover prefix string.
|
io.nats.client.ErrorListener |
getErrorListener() |
int |
getMaxPubAcksInFlight()
Returns the maximum number of publish ACKs that may be in flight at any point in time.
|
io.nats.client.Connection |
getNatsConnection()
Returns the NATS StreamingConnection, if set.
|
java.lang.String |
getNatsUrl()
Returns the NATS connection URL.
|
void |
setAckTimeout(java.time.Duration ackTimeout)
Sets the ACK timeout duration.
|
void |
setAckTimeout(long ackTimeout,
java.util.concurrent.TimeUnit unit)
Sets the ACK timeout in the specified time unit.
|
void |
setClientId(java.lang.String clientId)
Sets the client ID for the current NATS streaming session.
|
void |
setClusterId(java.lang.String clusterId)
Sets the cluster ID of the current NATS streaming session.
|
void |
setConnectionListener(io.nats.client.ConnectionListener l)
Set a connection listener for the underlying nats connection.
|
void |
setConnectTimeout(java.time.Duration connectTimeout)
Sets the connect timeout duration.
|
void |
setConnectTimeout(long connectTimeout,
java.util.concurrent.TimeUnit unit)
Sets the connect timeout in the specified time unit.
|
void |
setDiscoverPrefix(java.lang.String discoverPrefix)
Sets the discover prefix string that is used to establish a nats streaming session.
|
void |
setErrorListener(io.nats.client.ErrorListener l)
Set a error listener for the underlying nats connection.
|
void |
setMaxPubAcksInFlight(int maxPubAcksInFlight)
Sets the maximum number of publish ACKs that may be in flight at any point in time.
|
void |
setNatsConnection(io.nats.client.Connection natsConn)
Sets the NATS StreamingConnection.
|
void |
setNatsUrl(java.lang.String natsUrl)
Sets the NATS URL.
|
public StreamingConnectionFactory()
public StreamingConnectionFactory(java.lang.String clusterId,
java.lang.String clientId)
public StreamingConnection createConnection() throws java.io.IOException, java.lang.InterruptedException
java.io.IOException - if a StreamingConnection cannot be established for some reason.java.lang.InterruptedException - if the calling thread is interrupted before the connection can
be establishedpublic java.time.Duration getAckTimeout()
public void setAckTimeout(java.time.Duration ackTimeout)
ackTimeout - the pubAckWait to setpublic void setAckTimeout(long ackTimeout,
java.util.concurrent.TimeUnit unit)
ackTimeout - the pubAckWait to setunit - the time unit to setpublic java.time.Duration getConnectTimeout()
public void setConnectTimeout(java.time.Duration connectTimeout)
connectTimeout - the connectWait to setpublic void setConnectTimeout(long connectTimeout,
java.util.concurrent.TimeUnit unit)
connectTimeout - the connectWait to setunit - the time unit to setpublic java.lang.String getDiscoverPrefix()
public void setDiscoverPrefix(java.lang.String discoverPrefix)
discoverPrefix - the discoverPrefix to setpublic int getMaxPubAcksInFlight()
public void setMaxPubAcksInFlight(int maxPubAcksInFlight)
maxPubAcksInFlight - the maxPubAcksInFlight to setpublic java.lang.String getNatsUrl()
public void setNatsUrl(java.lang.String natsUrl)
natsUrl - the natsUrl to setpublic io.nats.client.Connection getNatsConnection()
public void setNatsConnection(io.nats.client.Connection natsConn)
natsConn - the NATS connection to setpublic java.lang.String getClientId()
public void setClientId(java.lang.String clientId)
clientId - the clientId to setpublic java.lang.String getClusterId()
public void setClusterId(java.lang.String clusterId)
clusterId - the clusterId to setpublic io.nats.client.ConnectionListener getConnectionListener()
public void setConnectionListener(io.nats.client.ConnectionListener l)
l - The new connection listenerpublic io.nats.client.ErrorListener getErrorListener()
public void setErrorListener(io.nats.client.ErrorListener l)
l - The new error listener