Search code examples
grailsqueuejobs

How to create a job and queue in a grails application


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


Solution

  • Based on the original question about Job and Queue, there are various ways you can have a message listener in your grails application. Some of them are:

    When job execution is concerned, the unanimous plugins would be either:

    Now coming to the objective of your question, you can also achieve the document upload functionality asynchronously if grails version is below 2.3 or you can leverage the Async support provided in Grails version 2.3 which sticks to "fire-and-forget" policy. User fires the document upload request and forgets about it, and gets notified when the task gets completed.

    If you are cognizant of "Promises" in common JS based frameworks (for eg: AngularJS) then using Promises in grails 2.3 will be an easier approach for you.