[appengine-java] Task Queue API Update

2011-01-23 Thread Doug


Good Afternoon All,

 I am working to convert from the Task Queue Labs API to the non-labs API 
version.  I am finding it slightly more difficult than I initially 
anticipated.  It appears that how I was adding tasks to the queue is not 
compatible with the non-labs API.  If I just update the imports to bring in 
the new API I get the error “The method url(String) is undefined for the 
type TaskOptions.Builder”.  I  have provide some example of my code below, 
if anyone else has converted can you give me some guidance on what I am 
doing wrong?

 

Current code, using the Labs API:
*import* *com.google.appengine.api.labs.taskqueue.Queue*;
*import* *com.google.appengine.api.labs.taskqueue.QueueFactory*;
*import* *com.google.appengine.api.labs.taskqueue.TaskOptions*;
*import* *com.google.appengine.api.labs.taskqueue.TaskOptions.Method*;
*import* *com.google.appengine.api.labs.taskqueue.TaskOptions.Builder*.*;

…

Queue add_queue = QueueFactory.getQueue(add);
…

for (int i = 1; i  Item_counter; i++) {

add_queue.add(TaskOptions.Builder.url(/add?item=+ItemURL[i]).method(Method.GET));
}

 

Code using the non-Labs API

import com.google.appengine.api.taskqueue.Queue;
import com.google.appengine.api.taskqueue.QueueFactory;
import com.google.appengine.api.taskqueue.TaskOptions;
import com.google.appengine.api.taskqueue.TaskOptions.Method;
import static com.google.appengine.api.taskqueue.TaskOptions.Builder.*;

 

TaskOptions TOdefault = 
com.google.appengine.api.taskqueue.TaskOptions.Builder.withDefaults();

…

for (int i = 1; i  Item_counter; i++) {

TaskOptions TO = new TaskOptions(TOdefault);
TO.url(/add);
TO.param(item, itemURL[i]);
TO.method(Method.GET);
add_queue.add(TO);
}


The new code compiles and will “run”, but I get all kinds of null pointer 
exceptions from the tasks when they try to run.  If I switch back to the 
labs API it works perfectly.  Can anyone help me understand what I need to 
do to either get my original code to work with the new API and/or what I did 
incorrectly with the updated code?


Thanks,
Doug

-- 
You received this message because you are subscribed to the Google Groups 
Google App Engine for Java group.
To post to this group, send email to google-appengine-java@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



Re: [appengine-java] Task Queue API Update

2011-01-23 Thread Fabrizio Accatino
Method names changed  :)

.url(...) -- withUrl(...)
.method(...) -- withMethod(...)


http://code.google.com/appengine/docs/java/javadoc/com/google/appengine/api/taskqueue/TaskOptions.Builder.html


Fabrizio

http://code.google.com/appengine/docs/java/javadoc/com/google/appengine/api/taskqueue/TaskOptions.Builder.html

On Sun, Jan 23, 2011 at 7:14 PM, Doug doug...@gmail.com wrote:

 Good Afternoon All,

  I am working to convert from the Task Queue Labs API to the non-labs API
 version.  I am finding it slightly more difficult than I initially
 anticipated.  It appears that how I was adding tasks to the queue is not
 compatible with the non-labs API.  If I just update the imports to bring
 in the new API I get the error “The method url(String) is undefined for the
 type TaskOptions.Builder”.  I  have provide some example of my code below,
 if anyone else has converted can you give me some guidance on what I am
 doing wrong?



 Current code, using the Labs API:
 *import* *com.google.appengine.api.labs.taskqueue.Queue*;
 *import* *com.google.appengine.api.labs.taskqueue.QueueFactory*;
 *import* *com.google.appengine.api.labs.taskqueue.TaskOptions*;
 *import* *com.google.appengine.api.labs.taskqueue.TaskOptions.Method*;
 *import* *com.google.appengine.api.labs.taskqueue.TaskOptions.Builder*.*;

 …

 Queue add_queue = QueueFactory.getQueue(add);
 …

 for (int i = 1; i  Item_counter; i++) {


 add_queue.add(TaskOptions.Builder.url(/add?item=+ItemURL[i]).method(Method.GET));
 }



 Code using the non-Labs API

 import com.google.appengine.api.taskqueue.Queue;
 import com.google.appengine.api.taskqueue.QueueFactory;
 import com.google.appengine.api.taskqueue.TaskOptions;
 import com.google.appengine.api.taskqueue.TaskOptions.Method;
 import static com.google.appengine.api.taskqueue.TaskOptions.Builder.*;



 TaskOptions TOdefault =
 com.google.appengine.api.taskqueue.TaskOptions.Builder.withDefaults();

 …

 for (int i = 1; i  Item_counter; i++) {

 TaskOptions TO = new TaskOptions(TOdefault);
 TO.url(/add);
 TO.param(item, itemURL[i]);
 TO.method(Method.GET);
 add_queue.add(TO);
 }


 The new code compiles and will “run”, but I get all kinds of null pointer
 exceptions from the tasks when they try to run.  If I switch back to the
 labs API it works perfectly.  Can anyone help me understand what I need to
 do to either get my original code to work with the new API and/or what I did
 incorrectly with the updated code?


 Thanks,
 Doug

  --
 You received this message because you are subscribed to the Google Groups
 Google App Engine for Java group.
 To post to this group, send email to
 google-appengine-java@googlegroups.com.
 To unsubscribe from this group, send email to
 google-appengine-java+unsubscr...@googlegroups.comgoogle-appengine-java%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/google-appengine-java?hl=en.


-- 
You received this message because you are subscribed to the Google Groups 
Google App Engine for Java group.
To post to this group, send email to google-appengine-java@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.