Class DefaultEventbus

All Implemented Interfaces:
MetricConstants, MoleculerLifecycle

public class DefaultEventbus extends Eventbus implements MetricConstants
Default EventBus implementation.
  • Field Details

    • listeners

      protected final HashMap<String, HashMap<String, Strategy<ListenerEndpoint>>> listeners
    • emitterCache

      protected final io.datatree.dom.Cache<String, Strategy<ListenerEndpoint>[]> emitterCache
    • broadcasterCache

      protected final io.datatree.dom.Cache<String, ListenerEndpoint[]> broadcasterCache
    • localBroadcasterCache

      protected final io.datatree.dom.Cache<String, ListenerEndpoint[]> localBroadcasterCache
    • checkVersion

      protected boolean checkVersion
      Check protocol version
    • protocolVersion

      protected String protocolVersion
      ServiceBroker's protocol version. Placeholder only: overwritten in started(broker) from broker.getProtocolVersion(). The authoritative default lives in ServiceBrokerConfig.DEFAULT_PROTOCOL_VERSION ("5").
    • nodeID

      protected String nodeID
      Local Node ID
    • writeErrorsToLog

      protected boolean writeErrorsToLog
      Write exceptions into the log file
    • streamTimeout

      protected long streamTimeout
      Stream 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 maxCallLevel
      Max call level (for nested events)
    • registryReadLock

      protected final Lock registryReadLock
      Reader lock of the Event Bus
    • registryWriteLock

      protected final Lock registryWriteLock
      Writer lock of the Event Bus
    • streamTimeoutTimer

      protected ScheduledFuture<?> streamTimeoutTimer
      Cancelable timer for request streams
    • strategy

      protected StrategyFactory strategy
    • transporter

      protected Transporter transporter
    • serviceInvoker

      protected ServiceInvoker serviceInvoker
    • scheduler

      protected ScheduledExecutorService scheduler
    • uidGenerator

      protected UidGenerator uidGenerator
    • metrics

      protected Metrics metrics
    • requestStreams

      protected final HashMap<String, IncomingStream> requestStreams
    • requestStreamReadLock

      protected final ReentrantReadWriteLock.ReadLock requestStreamReadLock
    • requestStreamWriteLock

      protected final ReentrantReadWriteLock.WriteLock requestStreamWriteLock
  • Constructor Details

    • DefaultEventbus

      public DefaultEventbus()
  • Method Details

    • started

      public void started(ServiceBroker broker) throws Exception
      Initializes default EventBus instance.
      Specified by:
      started in interface MoleculerLifecycle
      Overrides:
      started in class MoleculerComponent
      Parameters:
      broker - parent ServiceBroker
      Throws:
      Exception
    • stopped

      public void stopped()
      Specified by:
      stopped in interface MoleculerLifecycle
      Overrides:
      stopped in class MoleculerComponent
    • checkTimeouts

      protected void checkTimeouts()
    • receiveEvent

      public void receiveEvent(io.datatree.Tree message)
      Specified by:
      receiveEvent in class Eventbus
    • addListeners

      public void addListeners(String serviceName, Service service)
      Specified by:
      addListeners in class Eventbus
    • addListeners

      public void addListeners(String nodeID, io.datatree.Tree config)
      Specified by:
      addListeners in class Eventbus
    • removeListeners

      public void removeListeners(String nodeID)
      Specified by:
      removeListeners in class Eventbus
    • emit

      public void emit(Context ctx, Groups groups, boolean local)
      Specified by:
      emit in class Eventbus
    • emitInternal

      protected void emitInternal(Context ctx, Groups groups, boolean local)
    • stopStreaming

      protected void stopStreaming(Context ctx)
    • broadcast

      public void broadcast(Context ctx, Groups groups, boolean local)
      Specified by:
      broadcast in class Eventbus
    • broadcastInternal

      protected void broadcastInternal(Context ctx, Groups groups, boolean local)
    • logUnableToInvokeListener

      protected void logUnableToInvokeListener(Throwable cause)
    • getCacheKey

      protected String getCacheKey(String name, Groups groups)
    • generateListenerDescriptor

      public io.datatree.Tree generateListenerDescriptor(String service)
      Specified by:
      generateListenerDescriptor in class Eventbus
    • 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)