gpt4 book ai didi

java - Cloud Tasks 在\"specified\"区域不可用

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:23:40 25 4
gpt4 key购买 nike

我有一个在 App Engine 上运行的应用程序。有 2 个组件,一个在 App 引擎上执行,另一个在计算引擎上执行。他们通过任务队列进行通信。升级到版本 2 后出现以下错误:

   {
"code" : 400,
"errors" : [ {
"domain" : "global",
"message" : "Cloud Tasks is not available in the \"us-central1-f\" region.",
"reason" : "badRequest"
} ],
"message" : "Cloud Tasks is not available in the \"us-central1-f\" region.",
"status" : "INVALID_ARGUMENT"
}
at com.google.api.client.googleapis.json.GoogleJsonResponseException.from(GoogleJsonResponseException.java:146)
at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:113)
at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:40)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest$1.interceptResponse(AbstractGoogleClientRequest.java:321)
at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1049)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:419)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:352)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:469)
at com.ytg.infra.messaging.taskqueue_api.Quickstart.pullTask(Quickstart.java:147)
at com.ytg.infra.messaging.taskqueue_api.Quickstart.main(Quickstart.java:119)

注意:我已经传递了正确的参数。

最佳答案

经过一些研究我能够自己解决这个问题,下面我提供它的解决方案。

String queueNames = String.format("projects/%s/locations/%s/queues/%s", _projectName,_location, queueName);

// Create the PullTasksRequest
LeaseTasksRequest request = new LeaseTasksRequest().setMaxTasks(tasksBulkSize).setLeaseDuration(String.valueOf(leaseTimeInSecs)+"s").setResponseView("FULL");

//Execute the request and return the pulled task
LeaseTasksResponse response = _cloudTasksClient
.projects()
.locations()
.queues()
.tasks()
.lease(queueNames, request)
.execute();
return response.getTasks();

这解决了我的问题。抱歉发帖晚了。

关于java - Cloud Tasks 在\"specified\"区域不可用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48638949/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com