Server Push issue with pushing notifications for mutiple users


I am using Vaadin 7 Server Push in my application to push some notifications. Mutiple users can log into this applications at the same time. The notifications pushed are user specific i.e the notifications pushed to user are only those which the user subscribes. The notifications are read from a message queue.The message queue contains routing key i.e key that determines the user who subscribed to the notification.

The problem now is that even though I am able to get the correct notifications from message queues for each users, but while pushing the message, all users are getting the same or all the messages pushed.

I am executing the access runnable which pushes the message only on receiving the message which contains the same routing key. I have tried out all possible way to fix the problem atlast I came to a conclusion that the problem is in the access runnable. But I am not completely sure. So i need to know what as to be done to fix this issue.

My question is how to handle Server push when mutiple users uses the application at the same time and each users get different notifications.



You probably are using the wrong vaadin session to display the notifications.
How do you select the correct session for modifying the UI?

The way I handled this issue was, I have a static class I am calling the “Business Handler”, which contains static Listener lists for the different notifications I am trying to listen for. I add subscribe and unsubscribe methods in the class to subscribe to the different static Listener lists, and static “Fire” methods to trigger different event types for the listeners.

I then instantiate the Business Handler in my Vaadin UI class, and subscribe to it to listen for these Listeners.
In other places in the application I call the Fire methods, which then trigger the listeners that update my view.
This fires for all applications that have subscribed to this event type.

If you want to reserve the notifications for specific UI instances, if you were in my shoes, you could change the static listener lists to be Key Value pairs, the Key being of course your “Routing Key”, and the value being the listener.

Then, when calling the Fire method from anywhere, provide the “Routing Key” as a parameter to the Fire method, which you can use to compare against the list and find the UI you want to call a method on.