Search in sources :

Example 1 with Listener

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;
}
Also used : MessageMetadata(com.google.cloud.pubsublite.MessageMetadata) Listener(com.google.api.core.ApiService.Listener) State(com.google.api.core.ApiService.State)

Aggregations

Listener (com.google.api.core.ApiService.Listener)1 State (com.google.api.core.ApiService.State)1 MessageMetadata (com.google.cloud.pubsublite.MessageMetadata)1