This application is created for testing the
jakartaee-clustered-cdi-events
EJB module. It demonstrates with a Vaadin application how CDI events can be
transparently broadcasted within a WildFly (or any other Jakarta EE 8) cluster.
Broadcaster
: Manages event listeners and broadcasts messages to all registered consumers according to the Vaadin Broadcaster pattern.Message
: A simple message class marked with@Clustered
to enable cluster-wide event distribution.MainView
: A Vaadin view that allows users to send messages and view received broadcasts from local and other nodes.
Here's the component diagram:
You need Maven and Java 11 JDK to build and run the application.
First, build and install jakartaee-clustered-cdi-events
locally as it is not
published in Maven Central yet:
git clone https://github.com/mrts/jakartaee-clustered-cdi-events
pushd jakartaee-clustered-cdi-events
mvn clean install
popd
Then build the test application WAR with
mvn clean package -Pproduction
and deploy the resulting WAR to the application server.
See other configuration and running instructions in the
jakartaee-clustered-cdi-events
project
README.
- Open the URL http://localhost:8080/ in two different web browsers or use a normal and a private/incognito window in the same browser. This creates two separate user sessions for testing.
- Type a message in either browser and click "Broadcast" or "Async broadcast" in either browser. This sends a CDI event with the message.
- Both browsers will display the message received via the WebSocket protocol from the CDI event system.
The application can be run in a clustered configuration using the provided Docker and Docker Compose configuration files by running the following commands after building the application WAR:
docker-compose build
docker-compose up -d
In case docker-compose build
fails due to BuildKit errors, try building
without BuildKit:
DOCKER_BUILDKIT=0 docker-compose build
You can view the logs with:
docker-compose logs -f
Open http://localhost:8080/ and http://localhost:8081/ side-by-side in separate web browser windows and send broadcast messages as described above to test communication between the cluster nodes.
In the Docker Compose example cluster, a JMS cross-bridge is used for JMS clustering between two WildFly server instances. By cross-bridging JMS on these servers, the messages are replicated from a topic on one server to the same topic on the other.
The process involves:
- Setting up a user on both server instances that the JMS connection will use.
- Configuring a JMS bridge in instance A with the bridge’s source destination connecting to instance B.
- Similarly, configuring the bridge in instance B with the bridge’s source destination connecting to instance A.
The source and target destination of the bridge is the CLUSTER_CDI_EVENTS
topic used in jakartaee-clustered-cdi-events
.
The commands for adding the topic, bridge and other required configuration are in
config/wildfly-configuration-commands.cli
.
This project is licensed under the Apache License - see the LICENSE file for details.
Here's how to apply the license with addlicense
:
go install github.com/google/addlicense@latest
~/go/bin/addlicense -c 'Your Name' -s=only -l=apache src/