0

I have a grails application in which the user uploads a document and my application does various things with the uploaded file. Some of these tasks take a long time so the user has to wait to see the next page.

I want to change this behavior such that the user uploads the file and then immediately sees the next page. In the background the uploaded file will be queued. Later I want to pick-up files from the queue and process them in the order they were received.

What are some options available to a grails application to accomplish this? It'll be best if I can be pointed to a tutorial

4

2 回答 2

1

基于关于Joband的原始问题Queue,您可以通过多种方式在 grails 应用程序中使用消息侦听器。他们之中有一些是:

当涉及工作时execution,一致的插件将是:

现在谈到您的问题的目标,如果 grails 版本低于 2.3,您还可以异步实现文档上传功能,或者您可以利用Grails 版本 2.3 中提供的异步支持,该支持坚持“即发即弃”策略。用户触发文档上传请求并忘记它,并在任务完成时收到通知。

如果您了解常见的基于 JS 的框架(例如:AngularJS)中的“Promises”,那么在 grails 2.3 中使用 Promises 对您来说将是一种更简单的方法。

于 2013-07-15T04:26:51.230 回答
0

我认为您正在寻找类似 executorService 的东西

参考

您可以使用runasynch { }闭包来满足您的要求

于 2014-01-20T12:52:33.113 回答