A sample project to demonstrate the asynchronous communication between two spring boot apps producer and consumer through Apache ActiveMQ Artemis 2.4.0 using queue in a cluster mode.
- Apache ActiveMQ Artemis is a combined feature-set of ActiveMQ/HornetQ/Apollo. It provides a non blocking architecture for an outstanding performance.
- The project is configured to run on
local mode
(embedded server) andclustered mode
(different nodes) .
- Java 8
- Maven 3
- Spring Boot: 1.5.9.RELEASE
- Apache Artemis 2.4.0
${project-home} $ mvn clean package
${producer-home} $ mvn spring-boot:run -Dspring.profiles.active=local
${cosnsumer-home} $ mvn spring-boot:run -Dspring.profiles.active=local
Create the Cluster Brokers
$ ${apache-artemis-home}\bin\artemis create --force ${apache-artemis-broker-dest}\broker1
$ ${apache-artemis-home}\bin\artemis create --force ${apache-artemis-broker-dest}\broker2
$ ${apache-artemis-home}\bin\artemis create --force ${apache-artemis-broker-dest}\broker3
Configure Cluster Brokers
- Go to
${apache-artemis-broker-dest}
\broker1
\etc and replace content with${apache-artemis-home}\etc1\
- Go to
${apache-artemis-broker-dest}
\broker2
\etc and replace content with${apache-artemis-home}\etc2\
- Go to
${apache-artemis-broker-dest}
\broker3
\etc and replace content with${apache-artemis-home}\etc3\
Run the Nodes in the Cluster
$ ${apache-artemis-broker-dest}\broker1\bin\artemis run
$ ${apache-artemis-broker-dest}\broker2\bin\artemis run
$ ${apache-artemis-broker-dest}\broker3\bin\artemis run
Run the project in Cluster Mode
${project-home} $ mvn clean package
${producer-home} $ mvn spring-boot:run -Dspring.profiles.active=clustered-queue
${cosnsumer-home} $ mvn spring-boot:run -Dspring.profiles.active=node1
${cosnsumer-home} $ mvn spring-boot:run -Dspring.profiles.active=node2
${cosnsumer-home} $ mvn spring-boot:run -Dspring.profiles.active=node3