use of com.google.pubsub.v1.SubscriberGrpc.SubscriberFutureStub in project google-cloud-java by GoogleCloudPlatform.
the class Subscriber method startPollingConnections.
private void startPollingConnections() throws IOException {
synchronized (pollingSubscriberConnections) {
Credentials credentials = credentialsProvider.getCredentials();
CallCredentials callCredentials = credentials == null ? null : MoreCallCredentials.from(credentials);
for (int i = 0; i < numChannels; i++) {
SubscriberFutureStub stub = SubscriberGrpc.newFutureStub(channels.get(i));
if (callCredentials != null) {
stub = stub.withCallCredentials(callCredentials);
}
pollingSubscriberConnections.add(new PollingSubscriberConnection(cachedSubscriptionNameString, receiver, ackExpirationPadding, maxAckExtensionPeriod, ackLatencyDistribution, stub, flowController, flowControlSettings.getMaxOutstandingElementCount(), executor, alarmsExecutor, clock));
}
startConnections(pollingSubscriberConnections, new Listener() {
@Override
public void failed(State from, Throwable failure) {
// If a connection failed is because of a fatal error, we should fail the
// whole subscriber.
stopAllPollingConnections();
try {
notifyFailed(failure);
} catch (IllegalStateException e) {
if (isRunning()) {
throw e;
}
// It could happen that we are shutting down while some channels fail.
}
}
});
}
}
Aggregations