Class DatafeedLoopV1
- All Implemented Interfaces:
DatafeedLoop
This service will be started by calling DatafeedLoop.start()
At the beginning, a datafeed will be created and the BDK bot will listen to this datafeed to receive the real-time events. With datafeed service v1, we don't have the api endpoint to retrieve the datafeed id that a service account is listening, so, the id of the created datafeed must be persisted in the bot side.
The BDK bot will listen to this datafeed to get all the received real-time events.
From the second time, the bot will firstly retrieve the datafeed that was persisted and try to read the real-time events from this datafeed. If this datafeed is expired or faulty, the datafeed service 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
-
Constructor Summary
ConstructorDescriptionDatafeedLoopV1
(DatafeedApi datafeedApi, AuthSession authSession, com.symphony.bdk.core.config.model.BdkConfig config, UserV2 botInfo) DatafeedLoopV1
(DatafeedApi datafeedApi, AuthSession authSession, com.symphony.bdk.core.config.model.BdkConfig config, UserV2 botInfo, DatafeedIdRepository repository) -
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 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
-
Field Details
-
authSession
-
bdkConfig
protected final com.symphony.bdk.core.config.model.BdkConfig bdkConfig -
botInfo
-
started
-
datafeedApi
-
-
Constructor Details
-
DatafeedLoopV1
public DatafeedLoopV1(DatafeedApi datafeedApi, AuthSession authSession, com.symphony.bdk.core.config.model.BdkConfig config, UserV2 botInfo) -
DatafeedLoopV1
public DatafeedLoopV1(DatafeedApi datafeedApi, AuthSession authSession, com.symphony.bdk.core.config.model.BdkConfig config, UserV2 botInfo, DatafeedIdRepository repository)
-
-
Method Details
-
runLoop
- Throws:
Throwable
-
retrieveDatafeed
-
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
-