public class NatsTransporter extends Transporter implements io.nats.client.MessageHandler, io.nats.client.ConnectionListener
ServiceBroker broker = ServiceBroker.builder().nodeID("node1")
.transporter(new NatsTransporter("localhost")).build();
Required dependency:| Modifier and Type | Field and Description |
|---|---|
protected boolean |
advancedStats
Turn on advanced stats, primarily for test/benchmarks.
|
protected io.nats.client.AuthHandler |
authHandler
Optional AuthHandler.
|
protected int |
bufferSize
Sets the initial size for buffers in the connection.
|
protected io.nats.client.Connection |
client |
protected long |
connectionTimeout
Set the timeout for connection attempts in MILLISECONDS.
|
protected io.nats.client.Dispatcher |
dispatcher |
protected int |
maxPingsOut
Set the maximum number of pings the client can have in flight.
|
protected boolean |
noEcho
Turn off echo.
|
protected boolean |
noRandomize
Turn off server pool randomization.
|
protected boolean |
oldRequestStyle
Turn on the old request style that uses a new inbox and subscriber for
each request.
|
protected boolean |
opentls
Set the SSL context to one that accepts any server certificate and has no
client certificate.
|
protected java.lang.String |
password
Password for basic authentication.
|
protected boolean |
pedantic
Turn on pedantic mode for the server.
|
protected long |
pingInterval
Set the interval between attempts to pings the server in MILLISECONDS.
|
protected boolean |
secure
Use the default SSL Context, if it exists.
|
protected javax.net.ssl.SSLContext |
sslContext
Optional SSL Context.
|
protected java.util.concurrent.atomic.AtomicBoolean |
started |
protected java.lang.String[] |
urls
Nats server url(s).
|
protected java.lang.String |
username
Username for basic authentication.
|
protected boolean |
utf8Support
Enable UTF8 channels.
|
protected boolean |
verbose
Turn on verbose mode with the server.
|
checkTimeoutTimer, counterTransporterPacketsReceivedBytes, counterTransporterPacketsReceivedTotal, counterTransporterPacketsSentBytes, counterTransporterPacketsSentTotal, debug, debugHeartbeats, disconnectChannel, discoverBroadcastChannel, discoverChannel, eventbus, eventChannel, executor, gaugeTransitConnected, heartbeatChannel, heartbeatInterval, heartbeatTimeout, heartBeatTimer, infoBroadcastChannel, infoChannel, infoScheduled, infoScheduledAt, instanceID, lastReceivedMessageAt, metrics, monitor, namespace, nodeID, nodes, offlineTimeout, PACKET_DISCONNECT, PACKET_DISCOVER, PACKET_EVENT, PACKET_HEARTBEAT, PACKET_INFO, PACKET_PING, PACKET_PONG, PACKET_REQUEST, PACKET_RESPONSE, pingChannel, pongChannel, preferHostname, prefix, protocolVersion, registry, requestChannel, responseChannel, scheduler, serializer, serviceInvoker, subscriptionTimeout, uidGenerator, usingJsonSerializerbroker, logger, nameMOLECULER_CACHER_CLEAN_TIME, MOLECULER_CACHER_CLEAN_TIME_DESC, MOLECULER_CACHER_CLEAN_TOTAL, MOLECULER_CACHER_CLEAN_TOTAL_DESC, MOLECULER_CACHER_DEL_TIME, MOLECULER_CACHER_DEL_TIME_DESC, MOLECULER_CACHER_DEL_TOTAL, MOLECULER_CACHER_DEL_TOTAL_DESC, MOLECULER_CACHER_EXPIRED_TOTAL, MOLECULER_CACHER_EXPIRED_TOTAL_DESC, MOLECULER_CACHER_FOUND_TOTAL, MOLECULER_CACHER_FOUND_TOTAL_DESC, MOLECULER_CACHER_GET_TIME, MOLECULER_CACHER_GET_TIME_DESC, MOLECULER_CACHER_GET_TOTAL, MOLECULER_CACHER_GET_TOTAL_DESC, MOLECULER_CACHER_SET_TIME, MOLECULER_CACHER_SET_TIME_DESC, MOLECULER_CACHER_SET_TOTAL, MOLECULER_CACHER_SET_TOTAL_DESC, MOLECULER_CIRCUIT_BREAKER_HALF_OPENED_ACTIVE, MOLECULER_CIRCUIT_BREAKER_HALF_OPENED_ACTIVE_DESC, MOLECULER_CIRCUIT_BREAKER_OPENED_ACTIVE, MOLECULER_CIRCUIT_BREAKER_OPENED_ACTIVE_DESC, MOLECULER_CIRCUIT_BREAKER_OPENED_TOTAL, MOLECULER_CIRCUIT_BREAKER_OPENED_TOTAL_DESC, MOLECULER_EVENT_BROADCAST_TOTAL, MOLECULER_EVENT_BROADCAST_TOTAL_DESC, MOLECULER_EVENT_BROADCASTLOCAL_TOTAL, MOLECULER_EVENT_BROADCASTLOCAL_TOTAL_DESC, MOLECULER_EVENT_EMIT_TOTAL, MOLECULER_EVENT_EMIT_TOTAL_DESC, MOLECULER_EVENT_RECEIVED_ACTIVE, MOLECULER_EVENT_RECEIVED_ACTIVE_DESC, MOLECULER_EVENT_RECEIVED_ERROR_TOTAL, MOLECULER_EVENT_RECEIVED_ERROR_TOTAL_DESC, MOLECULER_EVENT_RECEIVED_TIME, MOLECULER_EVENT_RECEIVED_TIME_DESC, MOLECULER_EVENT_RECEIVED_TOTAL, MOLECULER_EVENT_RECEIVED_TOTAL_DESC, MOLECULER_EXECUTOR, MOLECULER_REQUEST_ACTIVE, MOLECULER_REQUEST_ACTIVE_DESC, MOLECULER_REQUEST_ERROR_TOTAL, MOLECULER_REQUEST_ERROR_TOTAL_DESC, MOLECULER_REQUEST_LEVELS, MOLECULER_REQUEST_LEVELS_DESC, MOLECULER_REQUEST_RETRY_ATTEMPTS_TOTAL, MOLECULER_REQUEST_RETRY_ATTEMPTS_TOTAL_DESC, MOLECULER_REQUEST_TIME, MOLECULER_REQUEST_TIME_DESC, MOLECULER_REQUEST_TIMEOUT_TOTAL, MOLECULER_REQUEST_TIMEOUT_TOTAL_DESC, MOLECULER_REQUEST_TOTAL, MOLECULER_REQUEST_TOTAL_DESC, MOLECULER_SCHEDULER, MOLECULER_TRANSIT_CONNECTED, MOLECULER_TRANSIT_CONNECTED_DESC, MOLECULER_TRANSIT_ORPHAN_RESPONSE_TOTAL, MOLECULER_TRANSIT_ORPHAN_RESPONSE_TOTAL_DESC, MOLECULER_TRANSIT_REQUESTS_ACTIVE, MOLECULER_TRANSIT_REQUESTS_ACTIVE_DESC, MOLECULER_TRANSIT_STREAMS_RECEIVE_ACTIVE, MOLECULER_TRANSIT_STREAMS_RECEIVE_ACTIVE_DESC, MOLECULER_TRANSPORTER_PACKETS_RECEIVED_BYTES, MOLECULER_TRANSPORTER_PACKETS_RECEIVED_BYTES_DESC, MOLECULER_TRANSPORTER_PACKETS_RECEIVED_TOTAL, MOLECULER_TRANSPORTER_PACKETS_RECEIVED_TOTAL_DESC, MOLECULER_TRANSPORTER_PACKETS_SENT_BYTES, MOLECULER_TRANSPORTER_PACKETS_SENT_BYTES_DESC, MOLECULER_TRANSPORTER_PACKETS_SENT_TOTAL, MOLECULER_TRANSPORTER_PACKETS_SENT_TOTAL_DESC| Constructor and Description |
|---|
NatsTransporter() |
NatsTransporter(java.lang.String... urls) |
NatsTransporter(java.lang.String username,
java.lang.String password,
boolean secure,
java.lang.String... urls) |
| Modifier and Type | Method and Description |
|---|---|
void |
connect() |
void |
connectionEvent(io.nats.client.Connection conn,
io.nats.client.ConnectionListener.Events type) |
protected void |
disconnect() |
protected void |
error(java.lang.Throwable cause)
Any I/O error occurred.
|
io.nats.client.AuthHandler |
getAuthHandler() |
int |
getBufferSize() |
long |
getConnectionTimeout() |
int |
getMaxPingsOut() |
java.lang.String |
getPassword() |
long |
getPingInterval() |
javax.net.ssl.SSLContext |
getSslContext() |
io.nats.client.Statistics |
getStatistics() |
java.lang.String[] |
getUrls() |
java.lang.String |
getUsername() |
boolean |
isAdvancedStats() |
boolean |
isNoEcho() |
boolean |
isNoRandomize() |
boolean |
isOldRequestStyle() |
boolean |
isOpentls() |
boolean |
isPedantic() |
boolean |
isSecure() |
boolean |
isUtf8Support() |
boolean |
isVerbose() |
void |
onMessage(io.nats.client.Message msg) |
void |
publish(java.lang.String channel,
io.datatree.Tree message) |
protected void |
reconnect() |
void |
setAdvancedStats(boolean advancedStats) |
void |
setAuthHandler(io.nats.client.AuthHandler authHandler) |
void |
setBufferSize(int bufferSize) |
void |
setConnectionTimeout(long connectionTimeout) |
void |
setMaxPingsOut(int maxPingsOut) |
void |
setNoEcho(boolean noEcho) |
void |
setNoRandomize(boolean noRandomize) |
void |
setOldRequestStyle(boolean oldRequestStyle) |
void |
setOpentls(boolean opentls) |
void |
setPassword(java.lang.String password) |
void |
setPedantic(boolean pedantic) |
void |
setPingInterval(long pingInterval) |
void |
setSecure(boolean secure) |
void |
setSslContext(javax.net.ssl.SSLContext sslContext) |
void |
setUrls(java.lang.String... urls) |
void |
setUsername(java.lang.String username) |
void |
setUtf8Support(boolean utf8Support) |
void |
setVerbose(boolean verbose) |
void |
stopped()
Closes transporter.
|
io.datatree.Promise |
subscribe(java.lang.String channel) |
broadcastInfoPacket, broadcastNodeConnected, broadcastNodeDisconnected, broadcastNodeUpdated, broadcastTransporterConnected, broadcastTransporterDisconnected, channel, checkTimeouts, connected, connected, createPingPacket, getAddress, getAllNodeIDs, getCpuUsage, getDescriptor, getHeartbeatInterval, getHeartbeatTimeout, getInstanceID, getLastHeartbeatTime, getNamespace, getOfflineTimeout, getPrefix, getSerializer, getSubscriptionTimeout, isDebug, isDebugHeartbeats, isOnline, isPreferHostname, processReceivedMessage, processReceivedMessage, publish, received, scheduleInfoPacket, sendClosePacket, sendDataPacket, sendDisconnectPacket, sendDiscoverPacket, sendErrorPacket, sendEventPacket, sendHeartbeatPacket, sendInfoPacket, sendPongPacket, sendRequestPacket, setDebug, setDebugHeartbeats, setHeartbeatInterval, setHeartbeatTimeout, setNamespace, setOfflineTimeout, setPreferHostname, setPrefix, setSerializer, setSubscriptionTimeout, started, subscribe, updateNodeInfogetBroker, getLogger, getNameprotected java.lang.String username
protected java.lang.String password
protected boolean secure
protected java.lang.String[] urls
protected javax.net.ssl.SSLContext sslContext
protected boolean noRandomize
protected int maxPingsOut
protected long pingInterval
protected long connectionTimeout
protected boolean verbose
protected int bufferSize
protected io.nats.client.AuthHandler authHandler
protected boolean noEcho
protected boolean utf8Support
protected boolean pedantic
protected boolean advancedStats
protected boolean opentls
protected boolean oldRequestStyle
protected io.nats.client.Connection client
protected io.nats.client.Dispatcher dispatcher
protected final java.util.concurrent.atomic.AtomicBoolean started
public NatsTransporter()
public NatsTransporter(java.lang.String... urls)
public NatsTransporter(java.lang.String username,
java.lang.String password,
boolean secure,
java.lang.String... urls)
public void connect()
connect in class Transporterpublic void connectionEvent(io.nats.client.Connection conn,
io.nats.client.ConnectionListener.Events type)
connectionEvent in interface io.nats.client.ConnectionListenerprotected void disconnect()
protected void reconnect()
protected void error(java.lang.Throwable cause)
Transportererror in class Transportercause - I/O errorpublic void stopped()
stopped in interface MoleculerLifecyclestopped in class Transporterpublic io.datatree.Promise subscribe(java.lang.String channel)
subscribe in class Transporterpublic void onMessage(io.nats.client.Message msg)
onMessage in interface io.nats.client.MessageHandlerpublic void publish(java.lang.String channel,
io.datatree.Tree message)
publish in class Transporterpublic io.nats.client.Statistics getStatistics()
public long getConnectionTimeout()
public void setConnectionTimeout(long connectionTimeout)
connectionTimeout - the connectionTimeout to setpublic int getBufferSize()
public void setBufferSize(int bufferSize)
bufferSize - the bufferSize to setpublic io.nats.client.AuthHandler getAuthHandler()
public void setAuthHandler(io.nats.client.AuthHandler authHandler)
authHandler - the authHandler to setpublic boolean isNoEcho()
public void setNoEcho(boolean noEcho)
noEcho - the noEcho to setpublic boolean isUtf8Support()
public void setUtf8Support(boolean utf8Support)
utf8Support - the utf8Support to setpublic boolean isPedantic()
public void setPedantic(boolean pedantic)
pedantic - the pedantic to setpublic boolean isAdvancedStats()
public void setAdvancedStats(boolean advancedStats)
advancedStats - the advancedStats to setpublic boolean isOpentls()
public void setOpentls(boolean opentls)
opentls - the opentls to setpublic java.lang.String getUsername()
public void setUsername(java.lang.String username)
username - the username to setpublic java.lang.String getPassword()
public void setPassword(java.lang.String password)
password - the password to setpublic boolean isSecure()
public void setSecure(boolean secure)
secure - the secure to setpublic java.lang.String[] getUrls()
public void setUrls(java.lang.String... urls)
urls - the urls to setpublic javax.net.ssl.SSLContext getSslContext()
public void setSslContext(javax.net.ssl.SSLContext sslContext)
sslContext - the sslContext to setpublic boolean isNoRandomize()
public void setNoRandomize(boolean noRandomize)
noRandomize - the noRandomize to setpublic int getMaxPingsOut()
public void setMaxPingsOut(int maxPingsOut)
maxPingsOut - the maxPingsOut to setpublic long getPingInterval()
public void setPingInterval(long pingInterval)
pingInterval - the pingInterval to setpublic boolean isVerbose()
public void setVerbose(boolean verbose)
verbose - the verbose to setpublic boolean isOldRequestStyle()
public void setOldRequestStyle(boolean oldRequestStyle)
oldRequestStyle - the oldRequestStyle to set