@API(status=INTERNAL) public class DatafeedLoopV2 extends AbstractAckIdEventLoop
This service will be started by calling AbstractDatafeedLoop.start()
At the beginning, the BDK bot will try to retrieve the list of datafeed to which it is listening. Since each bot should only listening to just one datafeed, the first datafeed in the list will be used by the bot to be listened to. If the retrieved list is empty, the BDK bot will create a new datafeed to listen.
The BDK bot will listen to this datafeed to get all the received real-time events.
If this datafeed becomes stale or faulty, the BDK bot will create the new one for listening.
This service will be stopped by calling AbstractDatafeedLoop.stop()
If the datafeed service is stopped during a read datafeed call, it has to wait until the last read finish to be really stopped
Modifier and Type | Field and Description |
---|---|
protected AuthSession |
authSession |
protected com.symphony.bdk.core.config.model.BdkConfig |
bdkConfig |
protected UserV2 |
botInfo |
protected DatafeedApi |
datafeedApi |
protected java.util.concurrent.atomic.AtomicBoolean |
started |
ackId, INITIAL_ACK_ID
Constructor and Description |
---|
DatafeedLoopV2(DatafeedApi datafeedApi,
AuthSession authSession,
com.symphony.bdk.core.config.model.BdkConfig config,
UserV2 botInfo) |
Modifier and Type | Method and Description |
---|---|
protected void |
handleV4EventList(java.util.List<V4Event> events)
Handle a received listener by using the subscribed
RealTimeEventListener . |
long |
lastPullTimestamp()
The timestamp of the last successful pulling
|
protected V5EventList |
readEvents() |
protected void |
refresh() |
protected void |
runLoop() |
void |
start()
Start the datafeed events service
|
void |
stop()
Stop the datafeed events service.
|
void |
subscribe(RealTimeEventListener listener)
The bot subscribes to a
RealTimeEventListener |
void |
unsubscribe(RealTimeEventListener listener)
The bot unsubscribes to a
RealTimeEventListener |
readAndHandleEvents
protected final AuthSession authSession
protected final com.symphony.bdk.core.config.model.BdkConfig bdkConfig
protected final UserV2 botInfo
protected final java.util.concurrent.atomic.AtomicBoolean started
protected DatafeedApi datafeedApi
public DatafeedLoopV2(DatafeedApi datafeedApi, AuthSession authSession, com.symphony.bdk.core.config.model.BdkConfig config, UserV2 botInfo)
protected void runLoop() throws java.lang.Throwable
java.lang.Throwable
protected V5EventList readEvents() throws com.symphony.bdk.http.api.ApiException
readEvents
in class AbstractAckIdEventLoop
com.symphony.bdk.http.api.ApiException
public void subscribe(RealTimeEventListener listener)
RealTimeEventListener
subscribe
in interface DatafeedLoop
listener
- a Datafeed event listener to be subscribedpublic void unsubscribe(RealTimeEventListener listener)
RealTimeEventListener
unsubscribe
in interface DatafeedLoop
listener
- a Datafeed event listener to be unsubscribedpublic void start() throws AuthUnauthorizedException, com.symphony.bdk.http.api.ApiException
start
in interface DatafeedLoop
AuthUnauthorizedException
com.symphony.bdk.http.api.ApiException
public void stop()
stop
in interface DatafeedLoop
protected void handleV4EventList(@Nullable java.util.List<V4Event> events) throws RequeueEventException
RealTimeEventListener
.events
- List of Datafeed events to be handledRequeueEventException
- Raised if a listener fails and the developer wants to explicitly not update the ack id.protected void refresh() throws AuthUnauthorizedException
AuthUnauthorizedException
public long lastPullTimestamp()
lastPullTimestamp
in interface DatafeedLoop