GWTP Action Handlers and Java Concurrency

62 views
Skip to first unread message

Jason Morris

unread,
Mar 16, 2015, 10:23:45 PM3/16/15
to gwt-pl...@googlegroups.com
Hi All,
In one of my GWTP Action Handlers, I was processing batches of uploaded files using ExecutorService.awaitTermination(timeout,TimeUnit.MILLISECONDS) method, holding up the action from returning immediately until the batch of tasks was done. For "small batches" of work, this was fine. But since a batch could take minutes to hours to complete, it was causing the network to timeout the request threads. Obviously, this was very bad, so I'm refactoring it.

My question(s) are:
  1. Does anyone have any good examples of using the Java concurrency package in conjunction with action handlers in GWTP?
  2. Are there any design patterns for submitting long-running batch jobs via GWTP such that the client can poll the server for progress?
  3. Is there a "GWTP best-practice" way to do this type of operation?
Thanks!
Cheers,
Jason

Christian Goudreau

unread,
Mar 24, 2015, 5:20:03 PM3/24/15
to gwt-pl...@googlegroups.com
If I understand correctly, it's timing out AFTER all files are uploaded and while your batch job?

1. Unfortunately not me.
2. I would suggest to consume the "task" and return immediately. Afterward, you can always send request to the server to validate if it's done or use long polling or use web sockets, atmosphere even maybe?. The key to that kind of process in my mind is to delegate the task to a task engine. And use other mechanisms to validate if it's ready or not. You could even have a timeout that says if more than X minutes, send an email once it's done.
3. see 2

Best regards,


Christian Goudreau | CEO - Président

--
You received this message because you are subscribed to the Google Groups "GWTP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gwt-platform...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jason Morris

unread,
Mar 25, 2015, 2:07:14 AM3/25/15
to gwt-platform
>> I would suggest to consume the "task" and return immediately.

Right, I agree. What I decided to try was to wrap the whole long-running task in its own thread, start that thread in the ActionHandler, and just allow the ActionHandler to return normally ASAP. As you suggested, I have a polling solution to get status on that long-running process.

For anyone who is interested, the approach I used to check progress was to have each java.util.concurrency.Callable that is executing on the "batch thread" write its progress, as an attribute keyed by string batchID, to the user's HttpSession object . Then, a separate polling GWTP Action run by a timer on the client can check process status by looking up that key. So far, it works great!

Jason C. Morris | PhD Candidate
Department of Environmental Sciences | Faculty of Agriculture and Environment
THE UNIVERSITY OF SYDNEY, NSW, 2006
phone: +61 02 8627 1152

--
You received this message because you are subscribed to a topic in the Google Groups "GWTP" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gwt-platform/1uAABH8sLjw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gwt-platform...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages