Here is how I start a task:

What it does is call the servlet and it in turn runs in the background. I 
also use a taskId to track it. This particular task sets up my app defaults. 
I also send in the login cookie, so I can authenticate who's logged in so 
random jane can't do it.

 private void setByTask(int defaultType) {
   
    String url = "/task?task=defaults&ownerid=" + sp.getUserThingId() + 
"&defaulttype=" + defaultType;
    
    String taskName = StringUtils.getRandomString(5) + "_" + url;
    long taskId = new Db_Feed_TaskQue(sp).saveTask(ThingData.THING_APPLICATION, 
taskName);
    
    url = url + "&taskid=" + taskId;
    
    try {
      TaskOptions taskOptions = 
TaskOptions.Builder.withUrl(url).header("Cookie", 
sp.getHeader("Cookie")).method(Method.GET);
      Queue queue = QueueFactory.getDefaultQueue();
      queue.add(taskOptions);
    } catch (Exception e) {
      new Db_Feed_TaskQue(sp).deleteTask(taskId);
      e.printStackTrace();
    }
    
  }


Brandon Donnelson
http://gwt-examples.googlecode.com
http://c.gawkat.com


-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.

Reply via email to