kotlin - 使用协程时警告 Apache Beam
问题描述
我的Kotlin项目正在使用Apache Beam和PubsubIO。在我尝试实现coroutine之前,一切正常。
这有效:
suspend fun main(args: Array<String>) { ... }
这有效,但会触发警告:
suspend fun main(args: Array<String>) = runBlocking<Unit> { ... }
WARNING: Application name is not set. Call Builder#setApplicationName.
Oct 22, 2021 11:53:52 AM com.google.api.client.googleapis.services.AbstractGoogleClient <init>
WARNING: Application name is not set. Call Builder#setApplicationName.
Oct 22, 2021 11:53:52 AM com.google.api.client.googleapis.services.AbstractGoogleClient <init>
WARNING: Application name is not set. Call Builder#setApplicationName.
Oct 22, 2021 11:53:52 AM com.google.api.client.googleapis.services.AbstractGoogleClient <init>
WARNING: Application name is not set. Call Builder#setApplicationName.
Oct 22, 2021 11:53:53 AM com.google.api.client.googleapis.services.AbstractGoogleClient <init>
WARNING: Application name is not set. Call Builder#setApplicationName.
Oct 22, 2021 11:53:53 AM com.google.api.client.googleapis.services.AbstractGoogleClient <init>
WARNING: Application name is not set. Call Builder#setApplicationName.
警告消息是垃圾邮件(每秒约 5/6 条消息),我找不到摆脱这些的方法。我没有AbstractGoogleClient
在我的代码中使用任何相关的东西,所以我真的不知道如何解决这个问题:
@Suppress
suspend fun main(args: Array<String>) = runBlocking<Unit> {
launch {
while (true) {
delay(1000L)
println("Testing...")
}
}
val options =
PipelineOptionsFactory.fromArgs(*args).withValidation().`as`(PipelineOptions::class.java)
val p = Pipeline.create(options)
p.apply<PCollection<String>>(
"Read messages from Pub/Sub",
PubsubIO.readStrings().fromSubscription(options.inputSubscription)
)
.apply("Processing", ParDo.of(ProcessData()))
p.run()
}
任何想法?
解决方案
您的问题与这里的Github 问题类似
设置要在每个请求的 UserAgent 标头中使用的应用程序名称,或 null 表示无。
UserAgent 标头示例:
"{application name} Google-API-Java-Client Google-HTTP-Java-Client/1.22.0 (gzip)"
也许这样的事情会解决警告(因为它表明Call Builder#setApplicationName)
val service = Builder(...)
.setHttpRequestInitializer(credentials)
.setApplicationName("Your app name")
.build()
推荐阅读
- oracle - plsql 错误“在“drug_name IN CHAR(255)”行上遇到符号(当期望以下之一时::-)“”
- android - 在 React Native 应用程序中集成三星健康的权限问题和步数
- python - 安装 pytorch 时出现“命令错误,退出状态 1”错误
- docker - 当 docker-compose 中的卷中的文件在 Dockerfile 中可用时?
- ruby-on-rails - 标题:- Amazon SP API 授权的标题问题
- c# - 在 C# webforms 中更新选中值(复选框)的 SQL
- rabbitmq - spring Rabbitmq运行时出现Bad frame end marker Error
- oracle - 如何使用 ASP.NET / EF Core(获取 ConnectionTimeout)为 Oracle 数据库设置正确的连接字符串?
- ssl - 无法安装 jmeter 的插件管理器
- gitlab - 为什么我们fork存储库后gitlab中显示的文件大小减小