简体   繁体   English

创建Google PULL队列有什么问题?

[英]What's wrong with my creation of Google PULL queue?

I'm a newbie in Google App Engine, so would you be so kind to clarify something for me? 我是Google App Engine的新手,所以您愿意为我澄清一些事情吗?

I'm creating a new PULL queue, this is my queue.xml 我正在创建一个新的PULL队列,这是我的queue.xml

<queue-entries>
    <queue>
        <name>app-metered-queue</name>
        <mode>pull</mode>
    </queue>
</queue-entries>

In my service, I instantiate a Queue instance with the following line of code 在我的服务中,我使用以下代码实例化Queue实例

private final Queue appMeteredQueue = QueueFactory.getQueue("app-metered-queue");

After I'm adding some data in it: 在其中添加一些数据后:

final List<TaskOptions> taskOptions = new ArrayList<>();
for (final Map.Entry<Long, Map<String, Map<String, Long>>> entry : bundledData.entrySet()) {
       taskOptions.add(TaskOptions.Builder
               .withPayload(mapper.writeValueAsString(entry.getValue()))
               .tag(String.valueOf(entry.getKey()))
       );
   }
appMeteredQueue.add(taskOptions);

but, unfortunately, an exception is thrown in .add() method : 但是,不幸的是, .add() method引发了异常:

java.lang.IllegalArgumentException: Only PULL tasks can have a tag.
    at com.google.appengine.api.taskqueue.QueueImpl.fillAddRequest(QueueImpl.java:335)

Could you please specify, what I'm doing wrong? 您能指出我在做什么错吗?

queue.xml isn't enough. queue.xml是不够的。

You should add .withMethod(TaskOptions.Method.PULL) to TaskOptions.Builder on a stage when you assemble TaskOptions . 您应该在组装TaskOptions的阶段将.withMethod(TaskOptions.Method.PULL)添加到TaskOptions.Builder TaskOptions

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM