public class NatsStreamingTransporter extends Transporter implements io.nats.client.ConnectionListener, io.nats.client.ErrorListener, io.nats.streaming.ConnectionLostHandler, io.nats.streaming.MessageHandler
ServiceBroker broker = ServiceBroker.builder().nodeID("node1").transporter(new NatsStreamingTransporter("localhost"))
.build();
Required dependency:| Modifier and Type | Field and Description |
|---|---|
protected java.time.Duration |
ackTimeout |
protected io.nats.streaming.StreamingConnection |
client
Nats connection.
|
protected java.lang.String |
clientId |
protected java.lang.String |
clusterId |
protected java.time.Duration |
connectTimeout |
protected java.lang.String |
discoverPrefix |
protected java.lang.Integer |
maxPubAcksInFlight |
protected java.util.concurrent.atomic.AtomicBoolean |
started |
protected java.lang.String |
url
Nats server url.
|
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 |
|---|
NatsStreamingTransporter() |
NatsStreamingTransporter(java.lang.String url) |
| Modifier and Type | Method and Description |
|---|---|
void |
connect() |
void |
connectionEvent(io.nats.client.Connection conn,
io.nats.client.ConnectionListener.Events type) |
void |
connectionLost(io.nats.streaming.StreamingConnection conn,
java.lang.Exception ex) |
protected void |
disconnect() |
protected void |
error(java.lang.Throwable cause)
Any I/O error occurred.
|
void |
errorOccurred(io.nats.client.Connection conn,
java.lang.String error) |
void |
exceptionOccurred(io.nats.client.Connection conn,
java.lang.Exception exp) |
java.time.Duration |
getAckTimeout() |
java.lang.String |
getClientId() |
java.lang.String |
getClusterId() |
java.time.Duration |
getConnectTimeout() |
java.lang.String |
getDiscoverPrefix() |
java.lang.Integer |
getMaxPubAcksInFlight() |
java.time.Duration |
getPingInterval() |
java.lang.Integer |
getPingsMaxOut() |
io.nats.streaming.SubscriptionOptions |
getSubscriptionOptions() |
java.lang.Boolean |
getTraceConnection() |
java.lang.String |
getUrl() |
void |
onMessage(io.nats.streaming.Message msg) |
void |
publish(java.lang.String channel,
io.datatree.Tree message) |
protected void |
reconnect() |
void |
setAckTimeout(java.time.Duration ackTimeout) |
void |
setClientId(java.lang.String clientId) |
void |
setClusterId(java.lang.String clusterId) |
void |
setConnectTimeout(java.time.Duration connectTimeout) |
void |
setDiscoverPrefix(java.lang.String discoverPrefix) |
void |
setMaxPubAcksInFlight(java.lang.Integer maxPubAcksInFlight) |
void |
setPingInterval(java.time.Duration pingInterval) |
void |
setPingsMaxOut(java.lang.Integer pingsMaxOut) |
void |
setSubscriptionOptions(io.nats.streaming.SubscriptionOptions subscriptionOptions) |
void |
setTraceConnection(java.lang.Boolean traceConnection) |
void |
setUrl(java.lang.String url) |
void |
slowConsumerDetected(io.nats.client.Connection conn,
io.nats.client.Consumer consumer) |
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 url
protected java.time.Duration connectTimeout
protected java.time.Duration ackTimeout
protected java.lang.String discoverPrefix
protected java.lang.Integer maxPubAcksInFlight
protected java.lang.String clientId
protected java.lang.String clusterId
protected io.nats.streaming.StreamingConnection client
protected final java.util.concurrent.atomic.AtomicBoolean started
public NatsStreamingTransporter()
public NatsStreamingTransporter(java.lang.String url)
public void connect()
connect in class Transporterprotected 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.streaming.Message msg)
onMessage in interface io.nats.streaming.MessageHandlerpublic void publish(java.lang.String channel,
io.datatree.Tree message)
publish in class Transporterpublic void connectionEvent(io.nats.client.Connection conn,
io.nats.client.ConnectionListener.Events type)
connectionEvent in interface io.nats.client.ConnectionListenerpublic void errorOccurred(io.nats.client.Connection conn,
java.lang.String error)
errorOccurred in interface io.nats.client.ErrorListenerpublic void exceptionOccurred(io.nats.client.Connection conn,
java.lang.Exception exp)
exceptionOccurred in interface io.nats.client.ErrorListenerpublic void slowConsumerDetected(io.nats.client.Connection conn,
io.nats.client.Consumer consumer)
slowConsumerDetected in interface io.nats.client.ErrorListenerpublic void connectionLost(io.nats.streaming.StreamingConnection conn,
java.lang.Exception ex)
connectionLost in interface io.nats.streaming.ConnectionLostHandlerpublic java.lang.String getUrl()
public void setUrl(java.lang.String url)
url - the url to setpublic java.time.Duration getConnectTimeout()
public void setConnectTimeout(java.time.Duration connectTimeout)
connectTimeout - the connectTimeout to setpublic java.time.Duration getAckTimeout()
public void setAckTimeout(java.time.Duration ackTimeout)
ackTimeout - the ackTimeout to setpublic java.lang.String getDiscoverPrefix()
public void setDiscoverPrefix(java.lang.String discoverPrefix)
discoverPrefix - the discoverPrefix to setpublic java.lang.Integer getMaxPubAcksInFlight()
public void setMaxPubAcksInFlight(java.lang.Integer maxPubAcksInFlight)
maxPubAcksInFlight - the maxPubAcksInFlight 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 java.time.Duration getPingInterval()
public void setPingInterval(java.time.Duration pingInterval)
pingInterval - the pingInterval to setpublic java.lang.Integer getPingsMaxOut()
public void setPingsMaxOut(java.lang.Integer pingsMaxOut)
pingsMaxOut - the pingsMaxOut to setpublic java.lang.Boolean getTraceConnection()
public void setTraceConnection(java.lang.Boolean traceConnection)
traceConnection - the traceConnection to setpublic io.nats.streaming.SubscriptionOptions getSubscriptionOptions()
public void setSubscriptionOptions(io.nats.streaming.SubscriptionOptions subscriptionOptions)
subscriptionOptions - the subscriptionOptions to set