Class RedisTransporter
java.lang.Object
services.moleculer.service.MoleculerComponent
services.moleculer.transporter.Transporter
services.moleculer.transporter.RedisTransporter
- All Implemented Interfaces:
io.lettuce.core.event.EventBus, io.lettuce.core.pubsub.RedisPubSubListener<byte[],byte[]>, MetricConstants, MoleculerLifecycle
public class RedisTransporter
extends Transporter
implements io.lettuce.core.event.EventBus, io.lettuce.core.pubsub.RedisPubSubListener<byte[],byte[]>
Redis Transporter. Redis is an open source (BSD licensed), in-memory data
structure store, used as a database, cache and message broker (website:
https://redis.io). Usage:
// https://mvnrepository.com/artifact/biz.paluch.redis/lettuce
compile group: 'biz.paluch.redis', name: 'lettuce', version: '4.5.0.Final'
ServiceBroker broker = ServiceBroker.builder().nodeID("node1")
.transporter(new RedisTransporter("localhost")).build();
Required dependency:// https://mvnrepository.com/artifact/biz.paluch.redis/lettuce
compile group: 'biz.paluch.redis', name: 'lettuce', version: '4.5.0.Final'
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected RedisPubSubClientprotected RedisPubSubClientprotected Stringprotected booleanprotected final AtomicIntegerprotected static final intprotected static final intprotected static final intprotected static final intprotected static final intprotected String[]Fields inherited from class Transporter
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, usingJsonSerializerFields inherited from class MoleculerComponent
broker, logger, nameFields inherited from interface MetricConstants
MOLECULER_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 Summary
ConstructorsConstructorDescriptionRedisTransporter(String... urls) RedisTransporter(String password, boolean secure, String... urls) -
Method Summary
Modifier and TypeMethodDescriptionvoidconnect()protected io.datatree.Promiseprotected voidAny I/O error occurred.reactor.core.publisher.Flux<io.lettuce.core.event.Event> get()String[]getUrls()booleanisSecure()voidmessage(byte[] channel, byte[] message) voidmessage(byte[] pattern, byte[] channel, byte[] message) voidpsubscribed(byte[] pattern, long count) voidpublish(io.lettuce.core.event.Event event) voidvoidpunsubscribed(byte[] pattern, long count) protected voidvoidsetPassword(String password) voidsetSecure(boolean secure) voidvoidstopped()Closes transporter.io.datatree.Promisevoidsubscribed(byte[] channel, long count) protected voidunableToConnect(Exception cause) voidunsubscribed(byte[] channel, long count) Methods inherited from class Transporter
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, updateNodeInfoMethods inherited from class MoleculerComponent
getBroker, getLogger, getNameMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.lettuce.core.pubsub.RedisPubSubListener
smessage, ssubscribed, sunsubscribed
-
Field Details
-
STATUS_DISCONNECTING
protected static final int STATUS_DISCONNECTING- See Also:
-
STATUS_DISCONNECTED
protected static final int STATUS_DISCONNECTED- See Also:
-
STATUS_CONNECTING_1
protected static final int STATUS_CONNECTING_1- See Also:
-
STATUS_CONNECTING_2
protected static final int STATUS_CONNECTING_2- See Also:
-
STATUS_CONNECTED
protected static final int STATUS_CONNECTED- See Also:
-
status
-
password
-
secure
protected boolean secure -
urls
-
clientSub
-
clientPub
-
-
Constructor Details
-
RedisTransporter
public RedisTransporter() -
RedisTransporter
-
RedisTransporter
-
-
Method Details
-
connect
public void connect()- Specified by:
connectin classTransporter
-
unableToConnect
-
disconnect
protected io.datatree.Promise disconnect() -
reconnect
protected void reconnect() -
error
Description copied from class:TransporterAny I/O error occurred. Implementation-specific error handling goes here (reconnection, etc.).- Overrides:
errorin classTransporter- Parameters:
cause- I/O error
-
stopped
public void stopped()Closes transporter.- Specified by:
stoppedin interfaceMoleculerLifecycle- Overrides:
stoppedin classTransporter
-
subscribe
- Specified by:
subscribein classTransporter
-
publish
- Specified by:
publishin classTransporter
-
message
public void message(byte[] channel, byte[] message) - Specified by:
messagein interfaceio.lettuce.core.pubsub.RedisPubSubListener<byte[],byte[]>
-
message
public void message(byte[] pattern, byte[] channel, byte[] message) - Specified by:
messagein interfaceio.lettuce.core.pubsub.RedisPubSubListener<byte[],byte[]>
-
subscribed
public void subscribed(byte[] channel, long count) - Specified by:
subscribedin interfaceio.lettuce.core.pubsub.RedisPubSubListener<byte[],byte[]>
-
psubscribed
public void psubscribed(byte[] pattern, long count) - Specified by:
psubscribedin interfaceio.lettuce.core.pubsub.RedisPubSubListener<byte[],byte[]>
-
unsubscribed
public void unsubscribed(byte[] channel, long count) - Specified by:
unsubscribedin interfaceio.lettuce.core.pubsub.RedisPubSubListener<byte[],byte[]>
-
punsubscribed
public void punsubscribed(byte[] pattern, long count) - Specified by:
punsubscribedin interfaceio.lettuce.core.pubsub.RedisPubSubListener<byte[],byte[]>
-
publish
public void publish(io.lettuce.core.event.Event event) - Specified by:
publishin interfaceio.lettuce.core.event.EventBus
-
get
public reactor.core.publisher.Flux<io.lettuce.core.event.Event> get()- Specified by:
getin interfaceio.lettuce.core.event.EventBus
-
getUrls
-
setUrls
-
getPassword
-
setPassword
-
isSecure
public boolean isSecure() -
setSecure
public void setSecure(boolean secure)
-