This project illustrates how you can use the AMQP JMS client from Apache Qpid to interact with AMQP 1.0 servers in a Quarkus application using the Quarkus Qpid JMS extension.
A step by step outline is available in the Quarkus website JMS guide, or quick overview details can be found below.
To use the quickstart, you first need a running AMQP 1.0 server. For example, you can follow the instructions from the Apache ActiveMQ Artemis web site, or run the broker using the ArtemisCloud container image:
docker run -it --rm -p 8161:8161 -p 61616:61616 -p 5672:5672 -e AMQ_USER=quarkus -e AMQ_PASSWORD=quarkus quay.io/artemiscloud/activemq-artemis-broker:latest
The application can be packaged using:
./mvnw package -DskipTests
The application is now runnable using:
java -jar target/quarkus-app/quarkus-run.jar
Then, open your browser to http://localhost:8080/prices.html, and you should see a button to fetch the latest price.
In addition to the prices.html page, the application is composed by 3 components:
PriceProducer
- the PriceProducer sends random prices to a JMS queue.PriceConsumer
- the PriceConsumer receives the JMS message and stores the last price.PriceResource
- the PriceResource gets the latest price from the PriceConsumer and returns it to the browser.
The client configuration is located in the application.properties configuration file.
You can compile the application into a native executable in a container using:
./mvnw clean package -Pnative -Dquarkus.native.container-build=true
The native application executable can then be run with:
./target/jms-quickstart-1.0.0-SNAPSHOT-runner