【发布时间】:2021-05-14 10:06:53
【问题描述】:
在 Google.Cloud.PubSub.V1 版本 1.x.x 中,我使用的是 PublisherServiceApiClient.Create 并传入配置有目标、凭据和 ChannelOptions 的“Channel”对象。 ChannelOptions 是 grpc.max_receive_message_length,然后是 grpc.max_send_message_length。
根据文档 (https://googleapis.github.io/google-cloud-dotnet/docs/Google.Cloud.PubSub.V1/api/Google.Cloud.PubSub.V1.SubscriberServiceApiClient.html#Google_Cloud_PubSub_V1_SubscriberServiceApiClient_Create),您必须使用 SubscriberServiceApiClientBuilder(如果您不打算使用默认值:https://googleapis.github.io/google-cloud-dotnet/docs/Google.Cloud.PubSub.V1/api/Google.Cloud.PubSub.V1.SubscriberServiceApiClientBuilder.html)。
SubscriberServiceApiClientBuilder 允许您设置 ChannelCredentials 和 Endpoint,但我看不到设置 ChannelOptions 的方法。如何在 SubscriberServiceApiClientBuilder 中设置 ChannelOptions?
旧代码用于创建 SubScriberServiceApiClient:
SubscriberServiceApiClient.Create(channel); // channel is of type Channel
新代码用于创建 SubscriberServiceApiClient:
new SubscriberServiceApiClientBuilder
{
ChannelCredentials = channelCredentials,
Endpoint = endPoint,
}.Build()
【问题讨论】: