Pasha
Pasha

Reputation: 1932

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?

Upvotes: 0

Views: 33

Answers (1)

Pasha
Pasha

Reputation: 1932

queue.xml isn't enough.

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

Upvotes: 1

Related Questions