Updating other users UI

Hello everyone,
I have an vaadin app in full java where other user can log in via Spring security. I want to inform the other users and their UI when data is updated in the backend. How can I achieve this ? I read about Vaadin push but that doesnt really work with the example on the documentation

You need a application scope event bus to communicate between sessions. And yes Push is needed as well. I have an old Vaadin 8 example with CDI here cdi-demo/src/main/java/org/vaadin/cdidemo/eventbus/EventBusImpl.java at master · TatuLund/cdi-demo · GitHub But as this is mostly agnostic what comes to Vaadin, it can be implemented same way with modern Vaadin apps as well. Spring has application scope which you can use instead of named singleton I have used in the CDI example.

There is also Vaadin product called Collaboration Kit, which builts on top of the idea of users being able to communicate concurrently within the application. The kit comes with the collaborative binder, so that users see who else are editing the same entity in the form and chat tool as well. So this product has much more sophistication than mere event bus (which naturally is there underneath). Collaboration Kit | Vaadin

Furthermore, my first example works only with case when you have application running only on a single node. Things become more complicated, when you can’t assume that all users are on the same server (i.e. application). Then you need external event sharing service. This kind of multi node support is found in Collaboration Kit as well.

@outstanding-hyena Which “example on the documentation” do you mean? We have quite a few.

I’m asking because this sounds like something we should improve in the docs.

@outstanding-hyena I have an example using Spring Events: GitHub - simasch/vaadin-spring-events

In the push section https://vaadin.com/docs/latest/advanced/server-push

@adaptable-uakari @yummy-rhino thank you guys I will have a look at it and try it out

@outstanding-hyena Would you give a bit more details what don’t work on that page? I copy pasted the sample to a trivial view (secured with Spring Security) and there all seems to work. Do you also use Spring Security on some related bean?

My use case: User A is doing something on the UI that updates the UI from User B. when I try to do it with UI.getCurrent().access( ()) and the push method the UI from User B is not updated. I am using Spring Security to secure view and having multiple user on my app

But that sounds exactly what I tested a moment ago.

Do you have @Push annotation in your Application class? (I assume you are using Spring Boot)

Or can you somehow otherwise check (browser inspector and the network tab) to check if websocket communication is active?

I have an @Push anotation on a empy class that implements AppShellConfigurator
image.png

and yes I am using Spring boot

putting the anotation on my main class leads to an error: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat

I usually do it like this:

@SpringBootApplication
@Push
public class Application implements AppShellConfigurator {

And I NEVER have used the PushMode.MANUAL

If you use that, you need to do something manually, and I have no reason to think why I would do that something better than the framework itself.