Skip to content

Commit

Permalink
fix: set maxInboundMetadataSize in pubsub (#3157)
Browse files Browse the repository at this point in the history
* fix: set maxInboundMetadataSize

* add comment

* add doc

* format doc
  • Loading branch information
JoeWang1127 authored Oct 3, 2024
1 parent b8ae0f0 commit f333e41
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions docs/src/main/asciidoc/pubsub.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ The behavior when the specified limits are exceeded. | No | Block
NOTE: By default, subscription-specific threads are named after fully-qualified subscription name, ex: `gcp-pubsub-subscriber-projects/project-id/subscriptions/subscription-name`.
This can be customized, by registering a `SelectiveSchedulerThreadNameProvider` bean.

NOTE: By default, subscription-specific `maxInboundMetadataSize` is set to 4MB.
This can be customized, by registering a `TransportChannelProvider` bean.

==== GRPC Connection Settings

The Pub/Sub API uses the https://cloud.google.com/pubsub/docs/reference/service_apis_overview#grpc_api[GRPC] protocol to send API requests to the Pub/Sub service.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,9 @@ public SubscriptionAdminClient subscriptionAdminClient(
@ConditionalOnMissingBean(name = "subscriberTransportChannelProvider")
public TransportChannelProvider subscriberTransportChannelProvider() {
return SubscriberStubSettings.defaultGrpcTransportProviderBuilder()
// default value specified by pubsub client library,
// see https://github.com/googleapis/java-pubsub/blob/main/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/Subscriber.java#L487.
.setMaxInboundMetadataSize(4 * 1024 * 1024)
.setKeepAliveTime(
Duration.ofMinutes(this.gcpPubSubProperties.getKeepAliveIntervalMinutes()))
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,17 @@ void maxInboundMessageSize_default() {
});
}

@Test
void maxInboundMetadataSize_default() {
contextRunner.run(
ctx -> {
TransportChannelProvider subscriberTcp =
ctx.getBean("subscriberTransportChannelProvider", TransportChannelProvider.class);
assertThat(FieldUtils.readField(subscriberTcp, "maxInboundMetadataSize", true))
.isEqualTo(4 * 1024 * 1024);
});
}

@Test
void retryableCodes_default() {
contextRunner.run(
Expand Down

0 comments on commit f333e41

Please sign in to comment.