1
votes

We are building analytics tool which collect events from web site and mobile apps. We want to process the request with Task queue in Google App engine. When i refer the doc in Google Developers site

 Queue queue = QueueFactory.getDefaultQueue();
 queue.add(withUrl("/analytics").param("id", String.valueOf(id)));

It has option to give only param. But how do i pass entire HTTP request to task queue and process them?

1

1 Answers

1
votes

I assume the main problem here is how to pass all the request parameters and the request body to the task.

Unfortunately there is no simple "relay" or "redirect" method to move your request to the task queue (but it would be nice). You have to use the Queue.add(TaskOptions taskOptions) method to add your task.

The recommended way to instantiate a TaskOptions object is to statically import TaskOptions.Builder.* and invoke a static creation method followed by an instance mutator (if needed).

And use one of the following (or any other payload() methods):

TaskOptions.payload(byte[] payload);
TaskOptions.payload(byte[] payload, String contentType);
TaskOptions.payload(String payload);

to set the content of the request. You can get the payload by reading it from the request.getInputStream().

The request parameters (if they are part of the URL and not the result of a form POST for example) you have to manually copy each with e.g. TaskOptions.param(String name, String value).