in my project we are using an JavaEE(CDI,Hibernate)-Backend deployed on a WildFly-Server with an AngularJS-Frontend.
Is there any simple way to push messages from within a war
-file to a Javascript-Client?
Thanks.
in my project we are using an JavaEE(CDI,Hibernate)-Backend deployed on a WildFly-Server with an AngularJS-Frontend.
Is there any simple way to push messages from within a war
-file to a Javascript-Client?
Thanks.
As you've mentioned JavaEE: Websockets are part of EE specification since version 7 - check https://docs.oracle.com/javaee/7/tutorial/websocket.htm.
The Websocket part of the spec is a bit rudimental, for example you have to implement things like topics, broadcasts or reconnect mechanisms by yourself (at least I couldn't find these functions in the specification). In case you need such functionalities it might make sense to take a look at socket.io (https://socket.io/) which can easily be integrated into Angular (https://tutorialedge.net/typescript/angular/angular-socket-io-tutorial/).
If polling (which is also implemented as a fallback in socket.io) is also an option, it's up to you what you prefer (and how complex the content should be). The EE specification is full of technologies with powerful abilities to return content: Servlets, JSF, JSP, JAX-RS, JAX-WS.
Just for clarification: Pushing or polling information with these solutions does only work when the clients have openend your web app in browser (even in background). If you also want to push information when they are not visiting your app you have to check solutions like Web Push Notifications from Google (https://developers.google.com/web/fundamentals/push-notifications/).
Hope this helps.