I want to use atmosphere to develop a notification System.
I am very new to Atmosphere so apologies if I am wrong somewhere. What i understood is when a Actor publishes something I save the notification action to the database. What i don't understand how the receiver will receive those notifications in realtime.
The sender i know will do something like following
event.getBroadcaster().broadcast(
objectMapper.writeValueAsString("Some Message"));
Now i am not able to figure out how the receiver can receive this message.
For example . I want to add a User Object as Friend. So when User1 adds User2 User1 broadcast but than how i push the notification to User2. I have difficulty in understanding this.
Technically i want something similar like facebook or gmail notification where on user activity other users get notifications.
Atmosphere supports WebSocket. If you want to write a java client you may want to try https://github.com/TooTallNate/Java-WebSocket
See section Writing your own WebSocket Client
Basically what you need is to implement Publish-subscribe on top of Atmosphere.
Atmosphere consists of two parts: client-side (javascript-based) and server-side(java-based).
First of all you need to configure server-side: Installing Atmosphere
Namely servlet or filter, it is required so that it could add AtmosphereResource to the HttpServletRequest.
AtmosphereResource represents a single client connection on the server-side.
Broadcaster is actually a container for these resources, so that you don't need to handle lookup/iteration/concurrency when you need to send to multiple connections. (Note that multiple connections can be produced by single client).
On the server-side you need to provide clients an endpoint to subscribe for notifications. For example, if you are using Spring-MVC, it could go like this (omitting validations/authentications, etc.):
When something happens you can notify clients like this:
On the client side you need to send a subscribe request and listen for subsequent events, like this:
So, to sum it up:
This wiki has explanations for some concepts behind Atmosphere and links to other documentation.