【发布时间】:2019-03-14 11:09:45
【问题描述】:
我正在与 Google Docs 争夺使用 PubSub 模拟器通过 .NET 设置 Cloud PubSub。
https://cloud.google.com/dotnet/docs/getting-started/using-pub-sub
https://cloud.google.com/pubsub/docs/publisher
https://cloud.google.com/pubsub/docs/emulator
来自 Rails 背景,我的任务是为 .NET 产品实现 Cloud PubSub,在 .NET Core 上运行我们的谷歌云,使其能够发布。
Google::Cloud::Pubsub.new(project: project_id, emulator_host: emulator_host)
从使用 .NET 的文档中,我不断回到以下内容:
PublisherServiceApiClient publisherClient = PublisherServiceApiClient.Create();
PublisherClient publisher = PublisherClient.Create(...)
但是,文档Google.Cloud.PubSub.V1 -Pre
中使用的库不包含定义。
'PublisherClient' does not contain a definition for 'Create'。
相反,我得到了CreateAsync,它包含TopicName、PublisherClient.ClientCreationSettings 和PublisherClient.Settings。
我注意到PublisherServiceApiClient 可以接收Channel,但我对如何实现这一点感到困惑。
以一个实际问题结束,目前如何在云中使用 .NET 实现 Cloud PubSub,然后使用模拟器在本地实现?除此之外,我是否使用了错误的库或错误的文档?
任何建议、指点或建议将不胜感激。
【问题讨论】:
-
这是有据可查的东西,可能太多了。。搜索后我找到了这个教程,它指导你如何设置你的开发环境。cloud.google.com/appengine/docs/flexible/dotnet/… 至于为什么你的 Create() 没有显示,可能是您缺少设置步骤..
-
不幸的是,该指南适用于 ASP.NET 应用程序,而我们的应用程序不是:/ 我认为该指南可能有一些内容,但似乎他们也在使用
PublisherClient.Create()。 .. -
我认为他们在 HelloWorld 教程中使用了 ASP .Net Core.. 还有更大的 Bookshelf 应用程序包罗万象的教程(可能也不是你想要的)cloud.google.com/dotnet/docs/getting-started/tutorial-app
-
是的,我最初是在使用 Bookshelf 应用教程,但同样的问题。
-
对于
PublisherClient,您确实应该使用CreateAsync。我们目前没有任何直接的仿真器支持,尽管正在进行的工作可能会使这更简单。你可以指定一个PublisherClient.ClientCreationSettings和一个合适的ServiceEndpoint和ChannelCredentials.Insecure来与模拟器对话。目前我不会为这个问题添加答案,因为这不是一个明确的问题to 答案 - 有些部分似乎是关于文档的,有些是关于创建的,还有一些是关于模拟器的。如果您可以针对特定问题澄清这一点,则添加答案会更容易。
标签: c# .net .net-core google-cloud-platform google-cloud-pubsub