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.
As of version 2.2.0 the way this class should be used has changed and accessors on this class are
deprecated. Instead create an Options.Builder, set the attributes there and assign that options builder
to a connection factory with setOptions or use the new constructor. New properties will only be added
to the options class and not replicated here. The existing accessors work, but should be moved away from.Constructor and Description |
---|
StreamingConnectionFactory()
Create a new, un-configured, connection factory.
|
StreamingConnectionFactory(Options options)
Create a connection factory with the specified cluster and client ids.
|
StreamingConnectionFactory(java.lang.String clusterId,
java.lang.String clientId)
Create a connection factory with the specified cluster and client ids.
|
Modifier and Type | Method and Description |
---|---|
StreamingConnection |
createConnection()
Creates an active connection to a NATS Streaming server.
|
java.time.Duration |
getAckTimeout()
Deprecated.
use options directly
|
java.lang.String |
getClientId()
Deprecated.
use options directly
|
java.lang.String |
getClusterId()
Deprecated.
use options directly
|
io.nats.client.ConnectionListener |
getConnectionListener()
Deprecated.
use options directly
|
java.time.Duration |
getConnectTimeout()
Deprecated.
use options directly
|
java.lang.String |
getDiscoverPrefix()
Deprecated.
use options directly
|
io.nats.client.ErrorListener |
getErrorListener()
Deprecated.
use options directly
|
int |
getMaxPubAcksInFlight()
Deprecated.
use options directly
|
io.nats.client.Connection |
getNatsConnection()
Deprecated.
use options directly
|
java.lang.String |
getNatsUrl()
Deprecated.
use options directly
|
void |
setAckTimeout(java.time.Duration ackTimeout)
Deprecated.
use options directly
|
void |
setAckTimeout(long ackTimeout,
java.util.concurrent.TimeUnit unit)
Deprecated.
use options directly
|
void |
setClientId(java.lang.String clientId)
Deprecated.
use options directly
|
void |
setClusterId(java.lang.String clusterId)
Deprecated.
use options directly
|
void |
setConnectionListener(io.nats.client.ConnectionListener l)
Deprecated.
use options directly
|
void |
setConnectTimeout(java.time.Duration connectTimeout)
Deprecated.
use options directly
|
void |
setConnectTimeout(long connectTimeout,
java.util.concurrent.TimeUnit unit)
Deprecated.
use options directly
|
void |
setDiscoverPrefix(java.lang.String discoverPrefix)
Deprecated.
use options directly
|
void |
setErrorListener(io.nats.client.ErrorListener l)
Deprecated.
use options directly
|
void |
setMaxPubAcksInFlight(int maxPubAcksInFlight)
Deprecated.
use options directly
|
void |
setNatsConnection(io.nats.client.Connection natsConn)
Deprecated.
use options directly
|
void |
setNatsUrl(java.lang.String natsUrl)
Deprecated.
use options directly
|
void |
setOptions(Options o)
Copies the options for use in future connections.
|
public StreamingConnectionFactory()
public StreamingConnectionFactory(java.lang.String clusterId, java.lang.String clientId)
clusterId
- the cluster id to connect toclientId
- the id for this client, with respect to the clusterpublic StreamingConnectionFactory(Options options)
options
- the options to create this factory withpublic 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 void setOptions(Options o)
o
- the options to copy@Deprecated public java.time.Duration getAckTimeout()
@Deprecated public void setAckTimeout(java.time.Duration ackTimeout)
ackTimeout
- the pubAckWait to set@Deprecated public void setAckTimeout(long ackTimeout, java.util.concurrent.TimeUnit unit)
ackTimeout
- the pubAckWait to setunit
- the time unit to set@Deprecated public java.time.Duration getConnectTimeout()
@Deprecated public void setConnectTimeout(java.time.Duration connectTimeout)
connectTimeout
- the connectWait to set@Deprecated public void setConnectTimeout(long connectTimeout, java.util.concurrent.TimeUnit unit)
connectTimeout
- the connectWait to setunit
- the time unit to set@Deprecated public java.lang.String getDiscoverPrefix()
@Deprecated public void setDiscoverPrefix(java.lang.String discoverPrefix)
discoverPrefix
- the discoverPrefix to set@Deprecated public int getMaxPubAcksInFlight()
@Deprecated public void setMaxPubAcksInFlight(int maxPubAcksInFlight)
maxPubAcksInFlight
- the maxPubAcksInFlight to set@Deprecated public java.lang.String getNatsUrl()
@Deprecated public void setNatsUrl(java.lang.String natsUrl)
natsUrl
- the natsUrl to set@Deprecated public io.nats.client.Connection getNatsConnection()
@Deprecated public void setNatsConnection(io.nats.client.Connection natsConn)
natsConn
- the NATS connection to set@Deprecated public java.lang.String getClientId()
@Deprecated public void setClientId(java.lang.String clientId)
clientId
- the clientId to set@Deprecated public java.lang.String getClusterId()
@Deprecated public void setClusterId(java.lang.String clusterId)
clusterId
- the clusterId to set@Deprecated public io.nats.client.ConnectionListener getConnectionListener()
@Deprecated public void setConnectionListener(io.nats.client.ConnectionListener l)
l
- The new connection listener@Deprecated public io.nats.client.ErrorListener getErrorListener()
@Deprecated public void setErrorListener(io.nats.client.ErrorListener l)
l
- The new error listener