Java GAE任务队列CallNotFoundException
尝试实现推送队列时,我遇到以下错误:Java GAE任务队列CallNotFoundException,java,google-app-engine,servlets,task-queue,Java,Google App Engine,Servlets,Task Queue,尝试实现推送队列时,我遇到以下错误: com.google.apphosting.api.ApiProxy$CallNotFoundException: Can't make API call taskqueue.BulkAdd in a thread that is neither the original request thread nor a thread created by ThreadManager 在我的servlet的doPost()方法中,我的任务如下: Queue que
com.google.apphosting.api.ApiProxy$CallNotFoundException: Can't make API call taskqueue.BulkAdd in a thread that is neither the original request thread nor a thread created by ThreadManager
在我的servlet的doPost()
方法中,我的任务如下:
Queue queue = QueueFactory.getQueue("rating-queue");
queue.add(TaskOptions.Builder.withUrl("/addrating")
.param("function", function)
.param("user_id", Integer.toString(user_id))
.param("item_id", Integer.toString(item_id))
.param("is_user", Boolean.toString(isUser)));
在我的web.xml
文件中:
<servlet>
<servlet-name>AddRating</servlet-name>
<servlet-class>com.example.ExampleClass</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>AddRating</servlet-name>
<url-pattern>/addrating</url-pattern>
</servlet-mapping>
增加
com.example.ExampleClass
增加
/增加
这是我的WEB-INF文件夹中的queue.xml文件:
<queue-entries>
<queue>
<name>default</name>
<rate>5/s</rate>
</queue>
<queue>
<name>rating-queue</name>
<rate>5/s</rate>
</queue>
</queue-entries>
违约
5/s
分级队列
5/s
我正在本地运行servlet。“我的应用程序引擎”控制台中没有可见的任务队列。您在哪里配置了队列“分级队列”?@MichaelMeyer请参见上文编辑到我的原始帖子不确定是否必须在配置文件中定义默认队列,但我建议删除queue.xml文件,并尝试改用QueueFactory.getDefaultQueue()。我只使用默认队列,没有任何配置file@MichaelMeyer最初我使用的是默认队列,但也返回了相同的错误。我切换到一个自定义队列,看看这是否有什么不同,但事实并非如此。是否可能是我正在使用的特定应用程序引擎API库?现在我正在使用Maven repository中的
com.google.appengine:appengine-api-1.0-sdk:1.9.51
。@user2122552我确实使用了。问题在于,任务队列只在标准环境中工作,而在灵活的环境中不工作。如果您使用的是灵活的环境,则可以使用。