From d0f8816bca3cfdc3646b6ffd258038f5e83b10d4 Mon Sep 17 00:00:00 2001 From: JoeWang1127 Date: Fri, 23 Aug 2024 21:03:50 +0000 Subject: [PATCH 1/4] fix: set maxInboundMetadataSize --- .../pubsub/GcpPubSubAutoConfiguration.java | 1 + .../pubsub/GcpPubSubAutoConfigurationTests.java | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/pubsub/GcpPubSubAutoConfiguration.java b/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/pubsub/GcpPubSubAutoConfiguration.java index 1d58496a64..37a643ee8b 100644 --- a/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/pubsub/GcpPubSubAutoConfiguration.java +++ b/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/pubsub/GcpPubSubAutoConfiguration.java @@ -436,6 +436,7 @@ public SubscriptionAdminClient subscriptionAdminClient( @ConditionalOnMissingBean(name = "subscriberTransportChannelProvider") public TransportChannelProvider subscriberTransportChannelProvider() { return SubscriberStubSettings.defaultGrpcTransportProviderBuilder() + .setMaxInboundMetadataSize(4 * 1024 * 1024) .setKeepAliveTime( Duration.ofMinutes(this.gcpPubSubProperties.getKeepAliveIntervalMinutes())) .build(); diff --git a/spring-cloud-gcp-autoconfigure/src/test/java/com/google/cloud/spring/autoconfigure/pubsub/GcpPubSubAutoConfigurationTests.java b/spring-cloud-gcp-autoconfigure/src/test/java/com/google/cloud/spring/autoconfigure/pubsub/GcpPubSubAutoConfigurationTests.java index 3f18d1e72c..86a16d8621 100644 --- a/spring-cloud-gcp-autoconfigure/src/test/java/com/google/cloud/spring/autoconfigure/pubsub/GcpPubSubAutoConfigurationTests.java +++ b/spring-cloud-gcp-autoconfigure/src/test/java/com/google/cloud/spring/autoconfigure/pubsub/GcpPubSubAutoConfigurationTests.java @@ -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( From c589f9c474819bf3258cc01d3fffe00b473aaf05 Mon Sep 17 00:00:00 2001 From: JoeWang1127 Date: Mon, 26 Aug 2024 14:12:42 +0000 Subject: [PATCH 2/4] add comment --- .../spring/autoconfigure/pubsub/GcpPubSubAutoConfiguration.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/pubsub/GcpPubSubAutoConfiguration.java b/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/pubsub/GcpPubSubAutoConfiguration.java index 37a643ee8b..0dab08655c 100644 --- a/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/pubsub/GcpPubSubAutoConfiguration.java +++ b/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/pubsub/GcpPubSubAutoConfiguration.java @@ -436,6 +436,8 @@ 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())) From c30d9fb75f272aec391fbea533598e6153870cdd Mon Sep 17 00:00:00 2001 From: Joe Wang Date: Sun, 8 Sep 2024 17:08:15 -0400 Subject: [PATCH 3/4] add doc --- docs/src/main/asciidoc/pubsub.adoc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/src/main/asciidoc/pubsub.adoc b/docs/src/main/asciidoc/pubsub.adoc index e3505e14fe..c722ecc10b 100644 --- a/docs/src/main/asciidoc/pubsub.adoc +++ b/docs/src/main/asciidoc/pubsub.adoc @@ -127,6 +127,12 @@ 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. From 9bbcaac48c7f25298321a20fbf7a751db3be0b54 Mon Sep 17 00:00:00 2001 From: Joe Wang Date: Sun, 8 Sep 2024 17:09:04 -0400 Subject: [PATCH 4/4] format doc --- docs/src/main/asciidoc/pubsub.adoc | 3 --- 1 file changed, 3 deletions(-) diff --git a/docs/src/main/asciidoc/pubsub.adoc b/docs/src/main/asciidoc/pubsub.adoc index c722ecc10b..f7af8f9bb3 100644 --- a/docs/src/main/asciidoc/pubsub.adoc +++ b/docs/src/main/asciidoc/pubsub.adoc @@ -129,9 +129,6 @@ This can be customized, by registering a `SelectiveSchedulerThreadNameProvider` NOTE: By default, subscription-specific `maxInboundMetadataSize` is set to 4MB. This can be customized, by registering a `TransportChannelProvider` bean. -==== - -==== ==== GRPC Connection Settings