I have a Vaadin 7.1.2 application with PUSH enabled.
The system uses the broadcast mechanism discussed in the book of vaadin
HERE (11.16.4) .
If I start up the app in several browsers, I see that each UI is correctly registering itself has a Broadcast Listener. However, when a broadcast message is sent, the listeners are traversed and the appropriate receiveBroadcast method is invoked. The individual listeners are unique.
The problem is that ALL messages appear to go to a single receiver. In other words, none of the other registered clients get a message from the Broadcaster.
Q: Any suggestions?
The issue discussed here may be similar to
this other issue.
Instead of using static methods on the Broadcaster , have you tried using a EJB Singleton ?
Not sure what application server you are using, but it might not be wise to rely on a Class ( Singleton pattern ) like that.
Hi Petrus, I converted the Broadcaster to Singleton (not EJB Singleton) but still same result. (btw, I am using Tomcat 7)
Then I converted to a Spring Service (a Singleton). Again, same behavior. Multiple browsers, different user accounts (logins), but only the first registered client gets the broadcasts.
Who is the ‘PUSH’ expert at Vaadin? Maybe they can let us know if this is a known problem…or operator error :-).
The key was locking the session in the receiver method.
public void receiveChat(final ChatPayload chatPayload) {
// Must lock the session to execute logic safely
[b]
access(new Runnable() {
[/b]
@Override
public void run() {
// Show it somehow
....
}
});
@Override
public void run() {
addValue(message);
UI.getCurrent().push();
}
});
}
[/code]I have a TextArea, which implements the BroadcastListner from the example. Even though I’m using the access-Method, it still only broadcast to the first registered listener inside the static list.
Anyone can help here?
For your information, I have Push set to manually.
}
[/code]So, when I’m registering the listener I also provide a direct reference of the UI not using UI.getCurrent().
Just in case someone comes across the same problem, maybe he can use the informations here.