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.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.
|
java.time.Duration |
getConnectTimeout()
Returns the connect timeout interval in milliseconds.
|
java.lang.String |
getDiscoverPrefix()
Returns the currently configured discover prefix string.
|
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 |
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 |
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 set