public class NatsConnector extends Object
| Constructor and Description |
|---|
NatsConnector() |
| Modifier and Type | Method and Description |
|---|---|
NatsConnector |
addConnectionStateListener(ConnectionStateListener listener)
Adds a
ConnectionStateListener to the client. |
NatsConnector |
addHost(String uri)
Adds a URI to the list of URIs that will be used to connect to a Nats server by the
Nats instance. |
NatsConnector |
addHost(URI uri)
Adds a URI to the list of URIs that will be used to connect to a Nats server by the
Nats instance. |
NatsConnector |
automaticReconnect(boolean automaticReconnect)
Indicates whether a reconnect should be attempted automatically if the Nats server connection fails.
|
NatsConnector |
calllbackExecutor(Executor executor)
Specifies the executor to use for invoking callbacks such as
ConnectionStateListener.onConnectionStateChange(Nats, nats.client.ConnectionStateListener.State) and
MessageHandler.onMessage(Message). |
Nats |
connect()
Creates the
Nats instance and asynchronously connects to the first Nats server provided using the
#addHost methods. |
NatsConnector |
eventLoopGroup(io.netty.channel.EventLoopGroup eventLoopGroup)
Specifies the Netty
EventLoopGroup to use for connecting to the Nats server(s). |
NatsConnector |
idleTimeout(long idleTimeout)
Specifies the time duration the connection to the NATS server may be idle before the client closes the
connection.
|
NatsConnector |
maxFrameSize(int maxFrameSize)
Specified the maximum message size that can be received by the Nats instance.
|
NatsConnector |
pedantic(boolean pedantic)
Indicates whether the server should do extra checking, mostly around properly formed subjects.
|
NatsConnector |
pingInterval(long pingInterval)
Specifies the time between sending ping requests to the Nats server.
|
NatsConnector |
reconnectWaitTime(long time,
TimeUnit unit)
Specifies the amount of time to wait between connection attempts.
|
public NatsConnector addHost(URI uri)
Nats instance.uri - a Nats URI referencing a Nats server.public NatsConnector addHost(String uri)
Nats instance.uri - a Nats URI referencing a Nats server.public NatsConnector automaticReconnect(boolean automaticReconnect)
true by default.automaticReconnect - whether a reconnect should be attempted automatically if the Nats server
connection fails.public NatsConnector eventLoopGroup(io.netty.channel.EventLoopGroup eventLoopGroup)
EventLoopGroup to use for connecting to the Nats server(s). (optional)eventLoopGroup - the Netty ChannelFactory to use for connecting to the Nats server(s)public NatsConnector pingInterval(long pingInterval)
pingInterval - the time between ping packets in milliseconds.public NatsConnector idleTimeout(long idleTimeout)
idleTimeout - time duration the connection to the NATS server may be idle before the client closes the
connectionpublic NatsConnector reconnectWaitTime(long time, TimeUnit unit)
time - the amount of time to wait between connection attempts.unit - the time unit of the time argumentpublic NatsConnector pedantic(boolean pedantic)
pedantic - indicates whether the server should do extra checking, mostly around properly formed subjectspublic NatsConnector maxFrameSize(int maxFrameSize)
maxFrameSize - the maximum message size that can be received by the Nats instance.public NatsConnector calllbackExecutor(Executor executor)
ConnectionStateListener.onConnectionStateChange(Nats, nats.client.ConnectionStateListener.State) and
MessageHandler.onMessage(Message).executor - the executor to use for invoking callbacks.public NatsConnector addConnectionStateListener(ConnectionStateListener listener)
ConnectionStateListener to the client. This allows you to be notified when a connection is
established, when the server is ready to process messages, and when the connection disconnects. If the
connection to the server closes unexpectedly, the client will automatically try to reconnect to the Cloud
Event Bus cluster.listener - the listener to usepublic Nats connect()
Nats instance and asynchronously connects to the first Nats server provided using the
#addHost methods.Nats instance.Copyright © 2015. All Rights Reserved.