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(20000); }
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/resteasy-users