use of com.google.api.core.ApiService.Listener in project beam by apache.
the class PublisherCache method get.
synchronized Publisher<MessageMetadata> get(PublisherOptions options) throws ApiException {
Publisher<MessageMetadata> publisher = livePublishers.get(options);
if (publisher != null) {
return publisher;
}
publisher = new PublisherAssembler(options).newPublisher();
livePublishers.put(options, publisher);
publisher.addListener(new Listener() {
@Override
public void failed(State s, Throwable t) {
logger.warn("Publisher failed.", t);
evict(options);
}
}, SystemExecutors.getFuturesExecutor());
publisher.startAsync().awaitRunning();
return publisher;
}
Aggregations