@API(status=INTERNAL)
public class DatafeedLoopV1
extends java.lang.Object
This service will be started by calling 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 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 com.symphony.bdk.http.api.ApiClient |
apiClient |
protected AuthSession |
authSession |
protected BdkConfig |
bdkConfig |
protected UserV2 |
botInfo |
protected DatafeedApi |
datafeedApi |
protected RetryWithRecoveryBuilder |
retryWithRecoveryBuilder |
Constructor and Description |
---|
DatafeedLoopV1(DatafeedApi datafeedApi,
AuthSession authSession,
BdkConfig config,
UserV2 botInfo) |
DatafeedLoopV1(DatafeedApi datafeedApi,
AuthSession authSession,
BdkConfig config,
UserV2 botInfo,
DatafeedIdRepository repository) |
Modifier and Type | Method and Description |
---|---|
protected java.lang.String |
createDatafeed() |
protected void |
handleV4EventList(java.util.List<V4Event> events)
Handle a received listener by using the subscribed
RealTimeEventListener . |
protected void |
refresh() |
protected java.util.Optional<java.lang.String> |
retrieveDatafeed() |
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 |
protected final AuthSession authSession
protected final BdkConfig bdkConfig
protected final UserV2 botInfo
protected final RetryWithRecoveryBuilder retryWithRecoveryBuilder
protected DatafeedApi datafeedApi
protected com.symphony.bdk.http.api.ApiClient apiClient
public DatafeedLoopV1(DatafeedApi datafeedApi, AuthSession authSession, BdkConfig config, UserV2 botInfo)
public DatafeedLoopV1(DatafeedApi datafeedApi, AuthSession authSession, BdkConfig config, UserV2 botInfo, DatafeedIdRepository repository)
public void start() throws AuthUnauthorizedException, com.symphony.bdk.http.api.ApiException
AuthUnauthorizedException
com.symphony.bdk.http.api.ApiException
public void stop()
protected java.lang.String createDatafeed() throws java.lang.Throwable
java.lang.Throwable
protected java.util.Optional<java.lang.String> retrieveDatafeed()
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 unsubscribedprotected void handleV4EventList(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