Class DefaultEventbus
java.lang.Object
services.moleculer.service.MoleculerComponent
services.moleculer.eventbus.Eventbus
services.moleculer.eventbus.DefaultEventbus
- All Implemented Interfaces:
MetricConstants, MoleculerLifecycle
Default EventBus implementation.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final io.datatree.dom.Cache<String, ListenerEndpoint[]> protected booleanCheck protocol versionprotected final io.datatree.dom.Cache<String, Strategy<ListenerEndpoint>[]> protected final io.datatree.dom.Cache<String, ListenerEndpoint[]> protected intMax call level (for nested events)protected Metricsprotected StringLocal Node IDprotected StringServiceBroker's protocol version.protected final LockReader lock of the Event Busprotected final LockWriter lock of the Event Busprotected final ReentrantReadWriteLock.ReadLockprotected final HashMap<String, IncomingStream> protected final ReentrantReadWriteLock.WriteLockprotected ScheduledExecutorServiceprotected ServiceInvokerprotected StrategyFactoryprotected longStream inactivity/read timeout in MILLISECONDS (0 = no timeout).protected ScheduledFuture<?> Cancelable timer for request streamsprotected Transporterprotected UidGeneratorprotected booleanWrite exceptions into the log fileFields 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddListeners(String nodeID, io.datatree.Tree config) voidaddListeners(String serviceName, Service service) voidprotected voidbroadcastInternal(Context ctx, Groups groups, boolean local) protected voidvoidprotected voidemitInternal(Context ctx, Groups groups, boolean local) io.datatree.TreegenerateListenerDescriptor(String service) protected StringgetCacheKey(String name, Groups groups) intlongbooleanbooleanprotected voidvoidreceiveEvent(io.datatree.Tree message) voidremoveListeners(String nodeID) voidsetCheckVersion(boolean checkVersion) voidsetMaxCallLevel(int maxCallLevel) voidsetStreamTimeout(long streamTimeout) voidsetWriteErrorsToLog(boolean writeErrorsToLog) voidstarted(ServiceBroker broker) Initializes default EventBus instance.voidstopped()protected voidstopStreaming(Context ctx) Methods inherited from class MoleculerComponent
getBroker, getLogger, getName
-
Field Details
-
listeners
-
emitterCache
-
broadcasterCache
-
localBroadcasterCache
-
checkVersion
protected boolean checkVersionCheck protocol version -
protocolVersion
ServiceBroker's protocol version. Placeholder only: overwritten instarted(broker)frombroker.getProtocolVersion(). The authoritative default lives inServiceBrokerConfig.DEFAULT_PROTOCOL_VERSION("5"). -
nodeID
Local Node ID -
writeErrorsToLog
protected boolean writeErrorsToLogWrite exceptions into the log file -
streamTimeout
protected long streamTimeoutStream inactivity/read timeout in MILLISECONDS (0 = no timeout). It may be useful if you want to remove the wrong packages from the memory. -
maxCallLevel
protected int maxCallLevelMax call level (for nested events) -
registryReadLock
Reader lock of the Event Bus -
registryWriteLock
Writer lock of the Event Bus -
streamTimeoutTimer
Cancelable timer for request streams -
strategy
-
transporter
-
serviceInvoker
-
scheduler
-
uidGenerator
-
metrics
-
requestStreams
-
requestStreamReadLock
-
requestStreamWriteLock
-
-
Constructor Details
-
DefaultEventbus
public DefaultEventbus()
-
-
Method Details
-
started
Initializes default EventBus instance.- Specified by:
startedin interfaceMoleculerLifecycle- Overrides:
startedin classMoleculerComponent- Parameters:
broker- parent ServiceBroker- Throws:
Exception
-
stopped
public void stopped()- Specified by:
stoppedin interfaceMoleculerLifecycle- Overrides:
stoppedin classMoleculerComponent
-
checkTimeouts
protected void checkTimeouts() -
receiveEvent
public void receiveEvent(io.datatree.Tree message) - Specified by:
receiveEventin classEventbus
-
addListeners
- Specified by:
addListenersin classEventbus
-
addListeners
- Specified by:
addListenersin classEventbus
-
removeListeners
- Specified by:
removeListenersin classEventbus
-
emit
-
emitInternal
-
stopStreaming
-
broadcast
-
broadcastInternal
-
logUnableToInvokeListener
-
getCacheKey
-
generateListenerDescriptor
- Specified by:
generateListenerDescriptorin classEventbus
-
isCheckVersion
public boolean isCheckVersion() -
setCheckVersion
public void setCheckVersion(boolean checkVersion) -
isWriteErrorsToLog
public boolean isWriteErrorsToLog() -
setWriteErrorsToLog
public void setWriteErrorsToLog(boolean writeErrorsToLog) -
getStreamTimeout
public long getStreamTimeout() -
setStreamTimeout
public void setStreamTimeout(long streamTimeout) -
getMaxCallLevel
public int getMaxCallLevel() -
setMaxCallLevel
public void setMaxCallLevel(int maxCallLevel)
-