[atmosphere-users] Atmosphere with Jersey, Spring and GWT

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[atmosphere-users] Atmosphere with Jersey, Spring and GWT

rengarajan_iyengar
Hi All,

I am trying to use Atmosphere with Jersey, Spring and GWT for sending
asynchronous notifications. To give a background about our application,
Spring is used in the backend for dependency injection and transaction
control. Jersey based RESTful services provide data for GWT based
browser client. GWT is only used on the client and remoting is done
thru Jersey.

The way I envision this to work is the browser based GWT client will
send a initial request to a RESTful service (a GET method) to initiate
the notifications. I will mark a method in RESTful service with
@Suspend notification and return a initial set of notifications (if
any). Another background service will periodically check if there are
new notifications in the database and will broadcast the notifications
to the suspended requests based on user information. This is the part I
am not sure how to get working with Atmosphere. So far, I tried writing
a AtmosphereHander based on ReflectiveServletProcessor. With this
approach, though I was able to send notifications to the suspended
clients,  the notifications appears as garbage on the browser (they are
supposed to be JSON messages) and also GWT doesn't seem to recognize
the chunks of data that Atmosphere is sending as GWT is not invoking
onResponseReceived message of RequestCallback when the chunk of data
reaches the browser.

Any help on this would be greatly appreciated.

Thanks,
Rajan
Reply | Threaded
Open this post in threaded view
|

[atmosphere-users] Re: Atmosphere with Jersey, Spring and GWT

java.net
Hi Rajan,

It will not be so straight forward to do what you describe. It will be
far easier to use the atmosphere-gwt module and connect this to your
existing infrastructure. You can still use your construction of
GWT/Jersey for your RESTful services and you can use atmosphere's
broadcaster scheme to do server push to your clients, which in turn will
be handled by the AtmosphereGWTHandler.
You can have a look at the gwt-demo sample project for a use case.

Hope this helps,
Pierre


On 3-10-2011 23:37, [hidden email] wrote:

> Hi All,
>
> I am trying to use Atmosphere with Jersey, Spring and GWT for sending
> asynchronous notifications. To give a background about our application,
> Spring is used in the backend for dependency injection and transaction
> control. Jersey based RESTful services provide data for GWT based
> browser client. GWT is only used on the client and remoting is done
> thru Jersey.
>
> The way I envision this to work is the browser based GWT client will
> send a initial request to a RESTful service (a GET method) to initiate
> the notifications. I will mark a method in RESTful service with
> @Suspend notification and return a initial set of notifications (if
> any). Another background service will periodically check if there are
> new notifications in the database and will broadcast the notifications
> to the suspended requests based on user information. This is the part I
> am not sure how to get working with Atmosphere. So far, I tried writing
> a AtmosphereHander based on ReflectiveServletProcessor. With this
> approach, though I was able to send notifications to the suspended
> clients,  the notifications appears as garbage on the browser (they are
> supposed to be JSON messages) and also GWT doesn't seem to recognize
> the chunks of data that Atmosphere is sending as GWT is not invoking
> onResponseReceived message of RequestCallback when the chunk of data
> reaches the browser.
>
> Any help on this would be greatly appreciated.
>
> Thanks,
> Rajan
Reply | Threaded
Open this post in threaded view
|

[atmosphere-users] Re: Atmosphere with Jersey, Spring and GWT

Salvatore Piccione
In reply to this post by rengarajan_iyengar
Hello,

I faced a situation similar to the one you depicted: the main difference is that my server-side was based on GWT as well as the client-side. I used atmosphere-0.7.1 and GWT 2.2.

Basically I defined the following classes:
  • a subclass of org.atmosphere.gwt.server.AtmosphereGwtHandler that handles the Comet connections requests coming from the clients and manages the Atmosphere Broadcaster instances (it delegates these activities to the BroadcasterManager below) - here is the code http://pastebin.com/ZX8bwWx7
  • a BroadcasterManager that actually manages Atmosphere Broadcaster (org.atmosphere.cpr.Broadcaster) instances performing actions like broadcaster storage and retrieval according to topic names - here is the code http://pastebin.com/mMrCZvzN
  • an EventQueueManager that fetches the events from an hypothetical EventQueue and broadcasts them to the clients (according to the topic/domain they are subscribed on) - here is the code http://pastebin.com/WZ5nk7t4
Hope this can help you. Notice that the snippets of code I linked are just samples and you won't be able to run them.

Salvatore

P.S. forwarding the discussion to the new Atmosphere ML: <[hidden email]>

2011/10/3 <[hidden email]>
Hi All,

I am trying to use Atmosphere with Jersey, Spring and GWT for sending
asynchronous notifications. To give a background about our application,
Spring is used in the backend for dependency injection and transaction
control. Jersey based RESTful services provide data for GWT based
browser client. GWT is only used on the client and remoting is done
thru Jersey.

The way I envision this to work is the browser based GWT client will
send a initial request to a RESTful service (a GET method) to initiate
the notifications. I will mark a method in RESTful service with
@Suspend notification and return a initial set of notifications (if
any). Another background service will periodically check if there are
new notifications in the database and will broadcast the notifications
to the suspended requests based on user information. This is the part I
am not sure how to get working with Atmosphere. So far, I tried writing
a AtmosphereHander based on ReflectiveServletProcessor. With this
approach, though I was able to send notifications to the suspended
clients,  the notifications appears as garbage on the browser (they are
supposed to be JSON messages) and also GWT doesn't seem to recognize
the chunks of data that Atmosphere is sending as GWT is not invoking
onResponseReceived message of RequestCallback when the chunk of data
reaches the browser.

Any help on this would be greatly appreciated.

Thanks,
Rajan