A sample project to demonstrate the asynchronous communication between two spring boot apps producer and consumer through Apache ActiveMQ Artemis 2.4.0 using topic
(publish-subscribe) 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
${topic-producer-home} $ mvn spring-boot:run -Dspring.profiles.active=local
${topic-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
${topic-producer-home} $ mvn spring-boot:run -Dspring.profiles.active=clustered-queue
${topic-cosnsumer-home} $ mvn spring-boot:run -Dspring.profiles.active=node1
${topic-cosnsumer-home} $ mvn spring-boot:run -Dspring.profiles.active=node2
${topic-cosnsumer-home} $ mvn spring-boot:run -Dspring.profiles.active=node3
- https://activemq.apache.org/artemis/docs/latest/clusters.html
- https://activemq.apache.org/artemis/docs/latest/examples.html
- https://github.com/apache/activemq-artemis/tree/master/examples/features/clustered
- http://javasampleapproach.com/java-integration/activemq-work-spring-jms-activemq-topic-publisher-subcribers-pattern-using-springboot
- https://stackoverflow.com/questions/47760168/durable-subscription-for-artemis-cluster-with-springboot