简体   繁体   中英

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?

I'm creating a new PULL queue, this is my 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

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 :

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.

You should add .withMethod(TaskOptions.Method.PULL) to TaskOptions.Builder on a stage when you assemble TaskOptions .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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