Class ConnectableService
java.lang.Object
info.bitrich.xchangestream.service.ConnectableService
public abstract class ConnectableService extends Object
Base class of streaming services, declares connect() method including before connection logic
-
Field Summary
Fields Modifier and Type Field Description static StringBEFORE_CONNECTION_HANDLERExchange specific parameter is used for providingRunnableaction which is caused before setup new connection. -
Constructor Summary
Constructors Constructor Description ConnectableService() -
Method Summary
Modifier and Type Method Description io.reactivex.Completableconnect()protected abstract io.reactivex.CompletableopenConnection()voidsetBeforeConnectionHandler(Runnable beforeConnectionHandler)
-
Field Details
-
BEFORE_CONNECTION_HANDLER
Exchange specific parameter is used for providingRunnableaction 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
-
openConnection
protected abstract io.reactivex.Completable openConnection() -
connect
public io.reactivex.Completable connect()
-