An example clinic patient queue application using Vaadin 8, Java EE 8 and Vaadin CDI add-on.
Demonstrates how to use Vaadin's server push and Java EE messaging APIs to send messages to client browsers in real time. Uses JMS 2.0 API for sending messages, message-driven beans for receiving them and a separate singleton broadcaster to broadcast messages to Vaadin UIs (the broadcaster is recommended by Vaadin as a bridge for connecting message-driven beans and Vaadin UIs that have different lifetimes).
Also demonstrates how to authenticate and authorize users using JAAS and Vaadin login form and view navigator.
Vaadin's server push uses a WebSocket connection by default which unfortunately
is not compatible
with CDI, so for the time
being a mixed communication mode with WebSocket for server to client and
XMLHttpRequest for client to server must be used with
@Push(transport = Transport.WEBSOCKET_XHR)
.
Tested with WildFly 18.0.1, but should work equally well with other Java EE 8 application servers.
The project consists of the following modules:
vaadin-javaee-clinic-patient-queue-example-ui
: main Vaadin application modulevaadin-javaee-clinic-patient-queue-example-backend
: backend module, contains server side code and dependencies.You need Maven and Java 8 JDK to build and run the application.
Build the application WAR with mvn package
, deploy it from
vaadin-javaee-clinic-patient-queue-example-ui/target/vaadin-javaee-clinic-patient-queue-example.war
to the application server.
Note that you need to run WildFly with full profile to enable JMS:
bin/standalone.{bat,sh} -c standalone-full.xml
The project consists of three apps:
If you have Google Chrome installed, you can launch all the apps in parallel
with launch-apps.sh
.
The following screencast shows the whole workflow in action:
A Vaadin TestBench test is also included, if you have a TestBench licence and Chrome WebDriver installed, you can run it with
mvn -Dtest=ClinicPatientQueueAppIT -DfailIfNoTests=false test
Prerequisite is that the application server is running the application in the background.
WildFly has a security realm called ApplicationRealm configured by default.
To add a new user to ApplicationRealm execute the add-user.{bat,sh}
script
within the bin
folder of your WildFly installation and enter the requested
information. Choose b) Application user and add the user to the group
users.
Add user user with password user for the test to work.