Skip to content
This repository was archived by the owner on May 8, 2026. It is now read-only.

Commit 52e23d6

Browse files
fix: set x-goog-request-params for streaming pull request (#1522)
* samples: schema evolution * samples: schema evolution * Format fixes * Fix documentation for field. * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * Add back in working asserts * Formatting fixes * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * Version/delete fixes * samples: schema evolution * samples: schema evolution * Format fixes * Fix documentation for field. * Add back in working asserts * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * Formatting fixes * Version/delete fixes * samples: Schema evolution (#1499) * samples: schema evolution * samples: schema evolution * Format fixes * Fix documentation for field. * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * Add back in working asserts * Formatting fixes * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * Version/delete fixes * samples: schema evolution * samples: schema evolution * Format fixes * Fix documentation for field. * Add back in working asserts * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * Formatting fixes * Version/delete fixes --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> * Minor fixes for comments * samples: Schema evolution (#1499) * samples: schema evolution * samples: schema evolution * Format fixes * Fix documentation for field. * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * Add back in working asserts * Formatting fixes * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * Version/delete fixes * samples: schema evolution * samples: schema evolution * Format fixes * Fix documentation for field. * Add back in working asserts * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * Formatting fixes * Version/delete fixes --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> * Fix rollback example * Formatting * Formatting and wording fixes * Add new schemas to test directory * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * Samples: Fix exception handling * fix: Set x-goog-request-params for streaming pull request * Revert "fix: Set x-goog-request-params for streaming pull request" This reverts commit 3185a3e. * Revert "Revert "fix: Set x-goog-request-params for streaming pull request"" This reverts commit 3b1f4d9. --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent d78b570 commit 52e23d6

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/StreamingSubscriberConnection.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
import com.google.api.gax.rpc.StreamController;
3737
import com.google.cloud.pubsub.v1.MessageDispatcher.AckProcessor;
3838
import com.google.cloud.pubsub.v1.stub.SubscriberStub;
39+
import com.google.common.collect.ImmutableList;
40+
import com.google.common.collect.ImmutableMap;
3941
import com.google.common.collect.Lists;
4042
import com.google.common.util.concurrent.MoreExecutors;
4143
import com.google.protobuf.Any;
@@ -86,6 +88,8 @@ final class StreamingSubscriberConnection extends AbstractApiService implements
8688

8789
private Duration inititalStreamAckDeadline;
8890

91+
private final Map<String, List<String>> streamMetadata;
92+
8993
private final SubscriberStub subscriberStub;
9094
private final int channelAffinity;
9195
private final String subscription;
@@ -134,6 +138,9 @@ private StreamingSubscriberConnection(Builder builder) {
134138
inititalStreamAckDeadline = builder.maxDurationPerAckExtension;
135139
}
136140

141+
streamMetadata =
142+
ImmutableMap.of("x-goog-request-params", ImmutableList.of("subscription=" + subscription));
143+
137144
subscriberStub = builder.subscriberStub;
138145
channelAffinity = builder.channelAffinity;
139146

@@ -273,7 +280,9 @@ private void initialize() {
273280
.streamingPullCallable()
274281
.splitCall(
275282
responseObserver,
276-
GrpcCallContext.createDefault().withChannelAffinity(channelAffinity));
283+
GrpcCallContext.createDefault()
284+
.withChannelAffinity(channelAffinity)
285+
.withExtraHeaders(streamMetadata));
277286

278287
logger.log(Level.FINER, "Initializing stream to subscription {0}", subscription);
279288
// We need to set streaming ack deadline, but it's not useful since we'll modack to send receipt

0 commit comments

Comments
 (0)