Re: [Resteasy-users] [repost]: Long task, short request
Have you tried the new async feature in servlet 3.0? RESTEasy supports it. -- Weinan Li Sent with Sparrow (http://www.sparrowmailapp.com/?sig) On Thursday, April 4, 2013 at 4:49 PM, Friso Vrolijken wrote: Hi all, I noticed that my previous message wasn't displayed correctly, so I'm trying this again (with adjusting line length). One thing I forgot to mention: I prefer an EJB-less solution. In future my solution may need to run on a web-profile app server. Thanks in advance, Friso -Oorspronkelijk bericht- Hi all, This post is (hopefully) mostly to confirm my thoughts. I've got a process that might take some time. I do not want the client to wait for the entire process however. If the client's input is valid, I just want to send the client a 200 response and handle any subsequent errors internally. My current solution for this is something like this: @Path (test) public class Test { // I'm not really instantiating it like this (but rather in a lazy // method), but do want to check if I should be using // newCachedThreadPool() // Should I be getting some named or configured ThreadPool private static ExecutorService executorService = Executors.newCachedThreadPool(); // ---^ this is the actual question @GET public static String bla (@QueryParam (me) String me) { if (me != null me.trim().length() 0) { //checking input // is this indeed the best way to go about this executorService.execute(new TestMe()); // ---^ this is the actual question // output, not important return Hallo + me; } return null; } private static class TestMe implements Runnable { @Override public void run() { System.out.println(TestMe); try { Thread.sleep(2); } catch (InterruptedException e) { e.printStackTrace(); } System.out.println(Done sleeping); } } } Which works, but I'm not sure if I'm handling the whole thread thing right (on JBoss 7AS). Any thoughts? Groeten, Friso -- Minimize network downtime and maximize team effectiveness. Reduce network management and security costs.Learn how to hire the most talented Cisco Certified professionals. Visit the Employer Resources Portal http://www.cisco.com/web/learning/employer_resources/index.html ___ Resteasy-users mailing list Resteasy-users@lists.sourceforge.net (mailto:Resteasy-users@lists.sourceforge.net) https://lists.sourceforge.net/lists/listinfo/resteasy-users -- Minimize network downtime and maximize team effectiveness. Reduce network management and security costs.Learn how to hire the most talented Cisco Certified professionals. Visit the Employer Resources Portal http://www.cisco.com/web/learning/employer_resources/index.html___ Resteasy-users mailing list Resteasy-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/resteasy-users
Re: [Resteasy-users] [repost]: Long task, short request
Hi Li, No, I’ve not tried that, as from the documentation I gather that the request will not return (i.e. the client will be kept waiting). One of my goals is to free up the client as soon as possible. Please let me know if my assumption (that the client needs to keep waiting) is incorrect. Groeten, Friso Van: Weinan Li [mailto:l.wei...@gmail.com] Verzonden: vrijdag 5 april 2013 13:06 Aan: Friso Vrolijken CC: resteasy-users@lists.sourceforge.net Onderwerp: Re: [Resteasy-users] [repost]: Long task, short request Have you tried the new async feature in servlet 3.0? RESTEasy supports it. -- Weinan Li Sent with Sparrowhttp://www.sparrowmailapp.com/?sig -- Minimize network downtime and maximize team effectiveness. Reduce network management and security costs.Learn how to hire the most talented Cisco Certified professionals. Visit the Employer Resources Portal http://www.cisco.com/web/learning/employer_resources/index.html___ Resteasy-users mailing list Resteasy-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/resteasy-users
Re: [Resteasy-users] Long task, short request
Not sure why this isn’t showing up in the list, so resending it... Van: Friso Vrolijken Verzonden: vrijdag 5 april 2013 13:10 Aan: resteasy-users@lists.sourceforge.net Onderwerp: RE: [Resteasy-users] [repost]: Long task, short request Hi Li, No, I’ve not tried that, as from the documentation I gather that the request will not return (i.e. the client will be kept waiting). One of my goals is to free up the client as soon as possible. Please let me know if my assumption (that the client needs to keep waiting) is incorrect. Groeten, Friso Van: Weinan Li Verzonden: vrijdag 5 april 2013 13:06 Aan: Friso Vrolijken CC: resteasy-users@lists.sourceforge.net Onderwerp: Re: [Resteasy-users] [repost]: Long task, short request Have you tried the new async feature in servlet 3.0? RESTEasy supports it. -- Weinan Li Sent with Sparrow -- Minimize network downtime and maximize team effectiveness. Reduce network management and security costs.Learn how to hire the most talented Cisco Certified professionals. Visit the Employer Resources Portal http://www.cisco.com/web/learning/employer_resources/index.html ___ Resteasy-users mailing list Resteasy-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/resteasy-users
Re: [Resteasy-users] Long task, short request
Friso, We had a similar problem on our project, Candlepin [1]. We have a number of items that end up being Quartz jobs that get kicked off via a POST call. Our POST methods return a JobDetail object [2], and we have an Interceptor [3] that on postProcess looks at the returned entity, if it's a JobDetail it returns HTTP.ACCEPTED [4] (202) and a status object that has a url to get status. The HTTP 202 code tells the client we got the request but it's not done yet. So far we've had pretty good success with this paradigm. I know we looked at the async feature in resteasy but I don't remember why we didn't end up using it. Sincerely, jesus [1] https://github.com/candlepin/candlepin [2] https://github.com/candlepin/candlepin/blob/master/src/main/java/org/candlepin/resource/MigrationResource.java [3] https://github.com/candlepin/candlepin/blob/master/src/main/java/org/candlepin/resteasy/interceptor/PinsetterAsyncInterceptor.java [4] http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.3 On Fri, Apr 5, 2013 at 9:34 AM, Friso Vrolijken friso.vrolij...@caci.nlwrote: Not sure why this isn’t showing up in the list, so resending it... Van: Friso Vrolijken Verzonden: vrijdag 5 april 2013 13:10 Aan: resteasy-users@lists.sourceforge.net Onderwerp: RE: [Resteasy-users] [repost]: Long task, short request Hi Li, No, I’ve not tried that, as from the documentation I gather that the request will not return (i.e. the client will be kept waiting). One of my goals is to free up the client as soon as possible. Please let me know if my assumption (that the client needs to keep waiting) is incorrect. Groeten, Friso Van: Weinan Li Verzonden: vrijdag 5 april 2013 13:06 Aan: Friso Vrolijken CC: resteasy-users@lists.sourceforge.net Onderwerp: Re: [Resteasy-users] [repost]: Long task, short request Have you tried the new async feature in servlet 3.0? RESTEasy supports it. -- Weinan Li Sent with Sparrow -- Minimize network downtime and maximize team effectiveness. Reduce network management and security costs.Learn how to hire the most talented Cisco Certified professionals. Visit the Employer Resources Portal http://www.cisco.com/web/learning/employer_resources/index.html ___ Resteasy-users mailing list Resteasy-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/resteasy-users -- Minimize network downtime and maximize team effectiveness. Reduce network management and security costs.Learn how to hire the most talented Cisco Certified professionals. Visit the Employer Resources Portal http://www.cisco.com/web/learning/employer_resources/index.html___ Resteasy-users mailing list Resteasy-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/resteasy-users