Class ConnectableService

java.lang.Object
info.bitrich.xchangestream.service.ConnectableService
Direct Known Subclasses:
NettyStreamingService

public abstract class ConnectableService
extends Object
Base class of streaming services, declares connect() method including before connection logic
  • Field Details

    • BEFORE_CONNECTION_HANDLER

      public static final String BEFORE_CONNECTION_HANDLER
      Exchange specific parameter is used for providing Runnable action which is caused before setup new connection. For example adding throttle control for limiting too often opening connections:
      
       static final TimedSemaphore limiter = new TimedSemaphore(1, MINUTES, 15);
       ExchangeSpecification spec = exchange.getDefaultExchangeSpecification();
       spec.setExchangeSpecificParameters(ImmutableMap.of(
         {@link ConnectableService#BEFORE_CONNECTION_HANDLER}, () -> limiter.acquire()
       ));
       
      See Also:
      Constant Field Values
  • Constructor Details

    • ConnectableService

      public ConnectableService()
  • Method Details

    • setBeforeConnectionHandler

      public void setBeforeConnectionHandler​(Runnable beforeConnectionHandler)
    • openConnection

      protected abstract io.reactivex.Completable openConnection()
    • connect

      public io.reactivex.Completable connect()