Class DatafeedLoopV2
- All Implemented Interfaces:
DatafeedLoop
This service will be started by calling DatafeedLoop.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 DatafeedLoop.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
-
Field Summary
Modifier and TypeFieldDescriptionprotected final AuthSession
protected final com.symphony.bdk.core.config.model.BdkConfig
protected final UserV2
protected DatafeedApi
protected final AtomicBoolean
Fields inherited from class com.symphony.bdk.core.service.datafeed.impl.AbstractAckIdEventLoop
ackId, INITIAL_ACK_ID
-
Constructor Summary
ConstructorDescriptionDatafeedLoopV2
(DatafeedApi datafeedApi, AuthSession authSession, com.symphony.bdk.core.config.model.BdkConfig config, UserV2 botInfo) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
handleV4EventList
(List<V4Event> events) Handle a received listener by using the subscribedRealTimeEventListener
.long
The timestamp of the last successful pullingprotected V5EventList
protected void
refresh()
protected void
runLoop()
void
start()
Start the datafeed events servicevoid
stop()
Stop the datafeed events service.void
subscribe
(RealTimeEventListener listener) The bot subscribes to aRealTimeEventListener
void
unsubscribe
(RealTimeEventListener listener) The bot unsubscribes to aRealTimeEventListener
Methods inherited from class com.symphony.bdk.core.service.datafeed.impl.AbstractAckIdEventLoop
readAndHandleEvents
-
Field Details
-
authSession
-
bdkConfig
protected final com.symphony.bdk.core.config.model.BdkConfig bdkConfig -
botInfo
-
started
-
datafeedApi
-
-
Constructor Details
-
DatafeedLoopV2
public DatafeedLoopV2(DatafeedApi datafeedApi, AuthSession authSession, com.symphony.bdk.core.config.model.BdkConfig config, UserV2 botInfo)
-
-
Method Details
-
runLoop
- Throws:
Throwable
-
readEvents
- Specified by:
readEvents
in classAbstractAckIdEventLoop
- Throws:
com.symphony.bdk.http.api.ApiException
-
subscribe
The bot subscribes to aRealTimeEventListener
- Specified by:
subscribe
in interfaceDatafeedLoop
- Parameters:
listener
- a Datafeed event listener to be subscribed
-
unsubscribe
The bot unsubscribes to aRealTimeEventListener
- Specified by:
unsubscribe
in interfaceDatafeedLoop
- Parameters:
listener
- a Datafeed event listener to be unsubscribed
-
start
Start the datafeed events service- Specified by:
start
in interfaceDatafeedLoop
- Throws:
AuthUnauthorizedException
com.symphony.bdk.http.api.ApiException
-
stop
public void stop()Stop the datafeed events service. The datafeed service will be stopped after a small delay to finish the last read datafeed call.- Specified by:
stop
in interfaceDatafeedLoop
-
handleV4EventList
Handle a received listener by using the subscribedRealTimeEventListener
.- Parameters:
events
- List of Datafeed events to be handled- Throws:
RequeueEventException
- Raised if a listener fails and the developer wants to explicitly not update the ack id.
-
refresh
- Throws:
AuthUnauthorizedException
-
lastPullTimestamp
public long lastPullTimestamp()The timestamp of the last successful pulling- Specified by:
lastPullTimestamp
in interfaceDatafeedLoop
- Returns:
- timestamp value in long
-