开发者

Grails Threading

I am trying to reduce blocking IO processing by using a threaded application. Basically I want to return a respond to the user while processing the information in the background. Can anyone point me in the right direction ? Please urgently need a solution.

Thanks in advance

-Additional Comments

I am building a front-end web-app that sends json data to the server to be saved. I want to send a respond back t开发者_如何转开发o the user without they have to wait for the database transaction. That operation will then be performed later in the background.


I have no idea if it will work for you (as you don't specify what your use-case is), but have you seen the Executor plugin for grails?

The docs can be found with the source on the related github page


Why don't you try the producer-consumer approach. You can look at spring events plugin http://www.grails.org/plugin/spring-events


This is my interpretation of what you are trying to say. Please correct me as I am not an expert in front end technologies and I can learn from this.

With basic ajax, there is usually one response back from the server, after the request has been completed. You want to server to send two notifications to the client/browser. one immediately after the server receives the request and one after the database-transaction/request is finished. If that is the case, then I guess you are particularly not interested in server side async ( the above can be achieved with or without it ). Server side async is part of servlet 3 and spring 3.1. Grails wont support this inherently until grails 2.0 reference here

Now, to achieve the above. Maybe comet could help. please read some notes here and here . With comet you essentially have a 2-way connection between server. so, you can send a notification to client whenever you want. so, you could send one response back to client immediately after the request and a second after the database transaction is complete.


There's a grails JMS Plugin which would use the old tried and true enterprise method of asynchronous execution by sending messages to grails services and letting those happen off on threads managed by the framework.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜