Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add randomly generated UUID to outgoing initial streaming pull requests #77

Merged
merged 6 commits into from Jan 31, 2020
Expand Up @@ -45,6 +45,7 @@
import com.google.pubsub.v1.StreamingPullResponse;
import io.grpc.Status;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
Expand Down Expand Up @@ -76,6 +77,13 @@ final class StreamingSubscriberConnection extends AbstractApiService implements
private final Lock lock = new ReentrantLock();
private ClientStream<StreamingPullRequest> clientStream;

/**
* The same clientId is used across all streaming pull connections that are created. This is
* intentional, as it indicates to the server that any guarantees made for a stream that
* disconnected will be made for the stream that is created to replace it.
*/
private final String clientId = UUID.randomUUID().toString();

public StreamingSubscriberConnection(
String subscription,
MessageReceiver receiver,
Expand Down Expand Up @@ -198,6 +206,7 @@ private void initialize() {
StreamingPullRequest.newBuilder()
.setSubscription(subscription)
.setStreamAckDeadlineSeconds(60)
.setClientId(clientId)
.build());

/**
Expand Down