views:

309

answers:

2

Can anyone think of a good way to allow the server to notify the client based upon server processing? For example, consider the following events:

  1. A user requests a deletion of data, however, due to it's long-running time, we kick it off to a queue.
  2. The client receives a "Yes we completed your transaction successfully".
  3. The server deletes the item and now wants to update any local structures any clients may be using (I'd also like to notify the user).

I know this can be done by client-side polling. Is there a event bus type way to do this? Any suggestions are welcome, but please keep in mind I am using GWT with App Engine.

A: 

The standard AJAX interaction is that the client sends requests to the server and expects some sort of response back fairly quickly.

In order for the server to initiate a request to the client, you will need to use WebSockets, and experimental HTML5 feature currently only supported by Chrome.

Or, to simulate this kind of interaction, you can use Comet (long-polling), made available in GWT by the rocket-gwt project.

Jason Hall
How does rocket-gwt manage to do comet on app engine?
Peter Recore
See docs at http://code.google.com/p/rocket-gwt/wiki/Comet
Jason Hall
You can't do comet on App Engine if you want to scale - each comet request will tie up one of your concurrent requests.
Nick Johnson
Is there a better way to accomplish this then?Instead of full-blown long-polling, the client could just ping every X seconds/minutes to see if the server has finished, but it won't be as real-time as comet/websockets.
Jason Hall
App Engine will soon release support for the Channel API, to support Comet-like functionality. To support this in GWT, see this example code: http://code.google.com/p/dance-dance-robot/source/browse/trunk/src/com/google/appengine/demos/dda/client/channel/
Jason Hall
A: 

You want server events for GWT? Have a look at GwtEventService (they couldn't have chosen a better name): http://code.google.com/p/gwteventservice/wiki/StartPage

Of course, it uses a Comet implementation, but you can't do any different when using HTTP, the client always initiates the communication. Request, response.

Jeroen