@API(status=INTERNAL)
public class DatafeedLoopV1
extends java.lang.Object
This service will be started by calling AbstractDatafeedLoop.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 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 |
Constructor and Description |
---|
DatafeedLoopV1(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) |
Modifier and Type | Method and Description |
---|---|
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() |
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 |
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 DatafeedLoopV1(DatafeedApi datafeedApi, AuthSession authSession, com.symphony.bdk.core.config.model.BdkConfig config, UserV2 botInfo)
public DatafeedLoopV1(DatafeedApi datafeedApi, AuthSession authSession, com.symphony.bdk.core.config.model.BdkConfig config, UserV2 botInfo, DatafeedIdRepository repository)
protected void runLoop() 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 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