At this point I'd suggest that you don't do it with GWT; step into the wayback 
machine and write a plain java servlet and do the necessary 
configuration/mapping with your web.xml.  Can you say old school?  There should 
be plenty of tutorials and samples on the web.

I'm thinking that you'd extend javax.servlet.http.HttpServlet and override its 
doGet() method.


John V Denley wrote:
> Wondering if this is now really a GWT question? Anyone got any ideas?
> 
> On Dec 14, 10:25 am, John V Denley <johnvden...@googlemail.com> wrote:
>> Thanks JD (slightly weird, I feel like Im writing to myself!) I think
>> we all understand what task queues are, the problem is how to actually
>> set up the functionality behind the URL
>>
>> I think we are getting close to a simple example, which I will post as
>> soon as I get this mechanism working. From what I can tell it works
>> something like this (which Im posing as a series of questions):
>>
>> Where should I put the function which extends the HttpServlet (eg
>> public class MyServletFunction extends HttpServlet {/*do something
>> useful*/}  )
>> I'm guessing it should be on the server side (eg as a new file within
>> com.myappname.server) called MyServletFunctionFile.java?
>> If so then should this be included somewhere OTHER than in the
>> myappname.gwt.xml file (eg  <servlet path="/MyServletFunction"
>> class="com.myappname.server.MyServletFunctionFile"/>)
>>
>> Im guessing that this would then mean that in theory I could type 
>> inhttp://myappname.appspot.com/MyServletFunctionto invoke the "/*do
>> something useful*/" code?
>>
>> Is there anything else I'm meant to define anywhere? Have I totally
>> misunderstood this process? If so then hopefully what Ive written here
>> illustrates the problems that some of us are having with getting our
>> head around some of these "basic" concepts!
>>
>> Thanks for everyones input and help so far here guys...
>>
>> Cheers,
>> J
>>
>> On Dec 14, 3:00 am, jd <jdpatter...@gmail.com> wrote:
>>
>>
>>
>>> Hi, task queues are just a way to call a url some time in the future.
>>> As Jason mentioned above, for a tasks "handler" you should probably
>>> just create a servlet (extend HttpServlet) because you do not need to
>>> generate a nice webpage as the result of the call - no one will see
>>> it.  In the HttpServlet.service(...) method write your code to
>>> actually handle the task making sure that it won't take longer than 30
>>> seconds.  This method will be called for POSTs or GETs to its url.
>>> Then you need to define the url that will call this servlet in your
>>> web.xml file.  If you are just using the default queue then you should
>>> map /_ah/queue/default to your "handler" servlet.
>>> To execute your task you could either call the url directly in a
>>> browser, from your GWT client or from other server side code.  But you
>>> probably want to use the TaskQueue to schedule the call for some time
>>> in the future from some other server side code like within your GWT
>>> RPC servlet.
>>> On Dec 14, 4:53 am, John VDenley<johnvden...@googlemail.com> wrote:
>>>> Well put Rusty, thats exactly the frustration im having!!! LOL
>>>> On Dec 13, 9:42 pm, Rusty Wright <rwright.li...@gmail.com> wrote:
>>>>> What method gets called in your code when your app receives a GET 
>>>>> request?  Or a POST request?  I think that's what you're looking for.  
>>>>> Unfortunately the documentation for these frameworks sometimes tries to 
>>>>> sugar coat things and hide ("abstract away") these low level details, or 
>>>>> they assume it's obvious how things work, which it may be to to some but 
>>>>> not all of us.
>>>>> John VDenleywrote:
>>>>>> LOL - damn... though it shouldnt matter whats being used for the front
>>>>>> end really....maybe Im asking the wrong question!!
>>>>>> Does anyone else have any idea how to explain what the entry point is
>>>>>> within the java code, or where the code is that actually executes what
>>>>>> thetaskqueueis supposed to do? Does anyone know how to ask the
>>>>>> question Im trying to ask?!
>>>>>> On Dec 13, 8:22 pm, Rusty Wright <rwright.li...@gmail.com> wrote:
>>>>>>> Heh, I'm on the flip side; I don't know anything about GWT.
>>>>>>> John VDenleywrote:
>>>>>>>> Thanks for this Rusty, Im not sure I understand all of it right away
>>>>>>>> (perhaps with more investigation I will work it out)
>>>>>>>> However Its worth mentioning that as far as I know Im not using Spring
>>>>>>>> or Stripes or Struts (not even sure what any of these are!)
>>>>>>>> I am using native GWT (v2.0)/GAE(v1.2.8) and using RPC to make calls
>>>>>>>> to the server side.
>>>>>>>> I have tried creating a "public" function in my main java file (right
>>>>>>>> above the onModuleLoad() function) as follows:
>>>>>>>>     public void testqueues()
>>>>>>>>     {
>>>>>>>>            Window.alert("hello test queues");
>>>>>>>>     }
>>>>>>>> The thinking then being that I might be able to make a call to
>>>>>>>> http://your-gae-app.appspot.com/testqueuesanditwouldshowthe alert
>>>>>>>> box. (I would like to prove this in the dev environment, but Im not
>>>>>>>> sure how to do this now that the URL for that is currently
>>>>>>>> http://localhost:8888/IDeBanet.html/testqueues?gwt.codesvr=192.168.0....)
>>>>>>>> Its entirely possible that I have totally misunderstood how this is
>>>>>>>> meant to be working and if so I apologise for asking stupid questions,
>>>>>>>> or making incorrect/confusing statements, but it seems theres no real
>>>>>>>> way of figuring out this stuff until you just try to implement it! Ive
>>>>>>>> learnt a huge amount about web development and in particular GWT/GAE
>>>>>>>> over the last 4-5 months!!
>>>>>>>> Cheers,
>>>>>>>> J
>>>>>>>> On Dec 13, 5:46 am, Rusty Wright <rwright.li...@gmail.com> wrote:
>>>>>>>>> I think I got the gist of it.  As a test I modified the Stripes 
>>>>>>>>> action bean that handles my first page and added the following to its 
>>>>>>>>> @DefaultHandler method:
>>>>>>>>>   finalQueuequeue= QueueFactory.getDefaultQueue();
>>>>>>>>>  queue.add(TaskOptions.Builder.url("/zugzug.zug")); // web.xml maps 
>>>>>>>>> *.zug to stripes
>>>>>>>>> It's adding ataskto thequeue.
>>>>>>>>> Then I created an action bean for thegaetaskqueueautomaton to poke:
>>>>>>>>>   @UrlBinding("/zugzug.zug")
>>>>>>>>>   public class TaskQueueActionBean implements ActionBean { ...
>>>>>>>>> and its @DefaultHandler method contains:
>>>>>>>>>   @SuppressWarnings("unchecked")
>>>>>>>>>   final List headerNames =
>>>>>>>>>           
>>>>>>>>> Collections.list(getContext().getRequest().getHeaderNames());
>>>>>>>>>   this.log.debug("header names: {}", headerNames);
>>>>>>>>> And then the log received:
>>>>>>>>>   header names: [Content-Type, User-Agent, Referer, Host, 
>>>>>>>>> X-AppEngine-QueueName, X-AppEngine-TaskName, 
>>>>>>>>> X-AppEngine-TaskRetryCount, Content-Length]
>>>>>>>>> The first time I tried it I forgot to create the corresponding jsp 
>>>>>>>>> view file, zugzug.jsp (which is essentially empty), and 
>>>>>>>>> thetaskqueueautomaton kept retrying because stripes was returning an 
>>>>>>>>> error because the jsp file was missing; lots of those log.debug lines 
>>>>>>>>> in the log file.  After I fixed that then it was only in there once 
>>>>>>>>> for each time I went to my first page.
>>>>>>>>> The first page action bean enqueued thetask, thetaskqueueautomaton 
>>>>>>>>> sent an http request to the url zugzug.zug, then the 
>>>>>>>>> TaskQueueActionBean was invoked and its success caused the automaton 
>>>>>>>>> to dequeue thetask(but not if it returned an error; then the 
>>>>>>>>> automaton retries).
>>>>>>>>> Rusty Wright wrote:
>>>>>>>>>> The docs say "The defaultqueuewill call the request handler at the 
>>>>>>>>>> URL
>>>>>>>>>> /worker ..."  So it sounds to me that if you were, forexample, using
>>>>>>>>>> Spring MVC, and had a Spring controller with
>>>>>>>>>> @Controller
>>>>>>>>>> @RequestMapping("/worker")
>>>>>>>>>> public final class WorkerController {
>>>>>>>>>>    @RequestMapping(method = RequestMethod.GET)
>>>>>>>>>>    public String handleGetRequest(final ModelMap model) {
>>>>>>>>>>        this.log.debug("called");
>>>>>>>>>>        return (null);
>>>>>>>>>>    }
>>>>>>>>>> }
>>>>>>>>>> then it would call your handleGetRequest() method 5 times a second, 
>>>>>>>>>> by
>>>>>>>>>> sending an http GET (or POST?) request to your /worker url each time.
>>>>>>>>>> Similarly, with Stripes (and for Struts 2 probably something 
>>>>>>>>>> similar) it
>>>>>>>>>> would be something like
>>>>>>>>>> @UrlBinding("/worker")
>>>>>>>>>> public class WorkerActionBean implements ActionBean {
>>>>>>>>>>    @DefaultHandler
>>>>>>>>>>    public Resolution handleRequest() {
>>>>>>>>>>        this.log.debug("called");
>>>>>>>>>>        return (null);
>>>>>>>>>>    }
>>>>>>>>>> }
>>>>>>>>>> I'm returning null because I don't know what thetaskqueuething does
>>>>>>>>>> with what it gets back (I didn't read much of their docs; to tell the
>>>>>>>>>> truth, I stopped at that sentence I quoted at the top because it 
>>>>>>>>>> sounds
>>>>>>>>>> very similar to their cron thing, which docs I did read most of).  
>>>>>>>>>> I'm
>>>>>>>>>> undoubtedly also lacking the code needed to pull the nexttaskoff the
>>>>>>>>>> queueand do something with it.
>>>>>>>>>> I'm assuming that you have some web framework in front of everything 
>>>>>>>>>> and
>>>>>>>>>> thus don't need a servlet mapping in your web.xml for the /worker url
>>>>>>>>>> since the web framework is handling the url mapping.
>>>>>>>>>> So they're "pinging" your /worker url using a plain old http request 
>>>>>>>>>> to
>>>>>>>>>> initiate running eachtask; your controller or action bean is what
>>>>>>>>>> performs thetask.  Think of it like you typed in your browser's 
>>>>>>>>>> address
>>>>>>>>>> boxhttp://your-gae-app.appspot.com/worker?task_queue_params_go_hereor
>>>>>>>>>> you used the command line programs cURL or wget.
>>>>>>>>>> If I understand this correctly then I would say that their sentence I
>>>>>>>>>> quoted isn't as clear as it could be.  Given the way it's stated, is 
>>>>>>>>>> the
>>>>>>>>>> taskqueuereally able to bypass all of the http request processing and
>>>>>>>>>> directly invoke my handler method?  How would it know which 
>>>>>>>>>> class+method
>>>>>>>>>> handles that url?  I would think that the servlet container calls the
>>>>>>>>>> request method, as a result of theirtaskqueueautomaton diddling the 
>>>>>>>>>> url.
>>>>>>>>>> John VDenleywrote:
>>>>>>>>>>> Yes, I would like a "real"exampleof how to do this too, I get that
>>>>>>>>>>> we need to use a URL to accept
>> ...
>>
>> read more ยป
> 
> --
> 
> 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-j...@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.
> 
> 

--

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-j...@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.


Reply via email to