Question

I currently have a controller that does a bit of heavy lifting processing (bulk csv file processing - cvs files ranging from 150Mb to 400Mb). The CSV files are uploaded to a temporary file location. Processing is done by a service that passes the file location to an APIs from an external jar (basic java API calling - no web service calls or anything). The service method takes about 2-3 times to return and the user has to wait currently for this time for the processing to complete and page to load after submitting a form - not the best user experience.

Grails users who have faced such a problem, what is the best solution to this kind of problem? I am new to Grails and JavaEE and hence this is basically a question on how one would architect such a system and the kind of libraries available for this.

I have googled quite a bit on this. People have responded with JMS, RabbitMQ etc as the solution to similar problems. But these appear to be swapping a fly with a bazooka kind of solution to my noob mind. Your suggestions are very much appreciated.

Thank you.

Was it helpful?

Solution

You can use the Spring @Async annotation on a service method if you want that method to be executed in a different thread. This is the approach I take in my Grails apps, it's dead easy.

There's an example of how to set it up here: http://tux2323.blogspot.co.uk/2012/05/grails-and-spring-async-annotation.html?m=1

OTHER TIPS

Use the quartz plugin... get the controller to schedule an immediate job (the scheduling is quick and the user will get a response straight away, and the processing will happen in a quartz job which runs in a different thread). Just notify the user when all the work is done (send an email or whatever).

Alternatively, use executor plugin to kick the job off in a new thread. 2.3 will have Async Support which could help here.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top