Aydin K.
Aydin K.

Reputation: 3368

Difference between Vaadin 7 Push and combination of Eventbus + immediate mode

I need to update different fields (tinycon and a badge on a button similar to the one on facebook) indicating the count of unread messages of the logged in user within my Vaadin7-Webapp.

So I started to setup Vaadin 7 Push feature but without success. On latest Tomcat (tested with: 7.0.61 and 8.0.30) and latest Vaadin (7.5.10) it just did not work. No error messages, but also no push. PushDemo from https://vaadin.com/wiki/-/wiki/Main/Enabling+server+push did also nothing. I guess the antivirus software of my company interrupts the underlying websocket communication.

But at the end, I achieved the desired result (=> updating field labels dynamically during runtime based on events) without Vaadin Push but with a simple combination sending an event via an Eventbus (Guava) and setting setimmediate(true) on the related GUI fields.

Question: Does this mean that I don't need Vaadin Push at all to achieve the desired functionality or am I missing something? Which advantage do I have with Push/Websockets / Is there any downside with my actual solution or is it analogous to the Vaadin-Push one?

Shorteneded question:

(From result aspects): Vaadin 7 Push equals Eventbus + immediate fields.

?

Upvotes: 1

Views: 527

Answers (1)

André Schild
André Schild

Reputation: 4754

setImmediate(true) isn't pushing or polling your server!

It just does a server roundtrip when the object is firing a event on client side. Also see this discussion about setImmediate.

The difference between polling and push are:

  • Push: The server informs the client about changes, otherwise no traffic flows between both
  • Polling: The client asks the server every X seconds if changes have been done
  • setImmediate(true): Updates only when the client sends a request to the server (Mostly ba some EventListeners defined in your UI. When the user does not move the mouse, no updates will every be shown

If push is not working, better use a polling object, which does a server interaction every x seconds. The progressbar component can be such a thing.

Upvotes: 3

Related Questions