services.FirehoseService Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of symphony-api-client-java Show documentation
Show all versions of symphony-api-client-java Show documentation
Symphony API Client provided by Symphony Platform Solutions team
package services;
import clients.SymBotClient;
import clients.symphony.api.FirehoseClient;
import exceptions.SymClientException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicBoolean;
import listeners.FirehoseListener;
import model.DatafeedEvent;
import model.events.MessageSent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class FirehoseService {
private final Logger logger = LoggerFactory.getLogger(FirehoseService.class);
private SymBotClient botClient;
private FirehoseClient firehoseClient;
private List listeners;
private String firehoseId;
private ExecutorService pool;
private AtomicBoolean stop = new AtomicBoolean();
public FirehoseService(SymBotClient client) {
this.botClient = client;
listeners = new ArrayList<>();
firehoseClient = this.botClient.getFirehoseClient();
firehoseId = firehoseClient.createFirehose();
readFirehose();
stop.set(false);
}
public FirehoseService(SymBotClient client, String firehoseId) {
this.botClient = client;
listeners = new ArrayList<>();
firehoseClient = this.botClient.getFirehoseClient();
this.firehoseId = firehoseId;
readFirehose();
stop.set(false);
}
public void addListener(FirehoseListener listener) {
listeners.add(listener);
}
public void removeListener(FirehoseListener listener) {
listeners.remove(listener);
}
public void readFirehose() {
if (pool != null) {
pool.shutdown();
}
pool = Executors.newFixedThreadPool(5);
CompletableFuture.supplyAsync(() -> {
while (!stop.get()) {
CompletableFuture
© 2015 - 2025 Weber Informatics LLC | Privacy Policy