Skip to content

amqphub/quarkus-qpid-jms-kubernetes-hello-world

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Getting started with JMS on Kubernetes using the Quarkus Qpid JMS extension

This guide shows you how to send and receive messages using Apache Qpid JMS and ActiveMQ Artemis on Kubernetes using a Quarkus Qpid JMS extension. It uses the AMQP 1.0 message protocol to send and receive messages.

Overview

The example application has three parts:

  • An AMQP 1.0 message broker, ActiveMQ Artemis

  • A sender service exposing an HTTP endpoint that converts HTTP requests into AMQP 1.0 messages. It sends the messages to a queue called example/strings on the broker.

  • A receiver service that consumes AMQP messages from example/strings. It exposes another HTTP endpoint that returns the messages as HTTP responses.

The sender and the receiver use the JMS API to perform messaging operations.

Prerequisites

Steps

  1. Change directory to the sender application, build it to prepare for creating a docker image to deploy.

    $ cd sender/
    $ mvn package -Pnative -Dnative-image.docker-build=true
    [Maven output]
    cd ../
  2. Change directory to the receiver application, build it to prepare for creating a docker image to deploy.

    $ cd receiver/
    $ mvn package -Pnative -Dnative-image.docker-build=true
    [Maven output]
    cd ../
  3. Configure your shell to use the Minikube Docker instance:

    $ eval $(minikube docker-env)
    $ echo $DOCKER_HOST
    tcp://192.168.39.67:2376
  4. Create a broker deployment and expose it as a service:

    $ kubectl run messaging --generator=run-pod/v1 --image docker.io/ssorj/activemq-artemis
    pod/messaging created
    $ kubectl expose pod messaging --type=ClusterIP --port=5672
    service/messaging exposed
  5. Change directory to the sender application, create a deployment, and expose it as a service:

    $ cd sender/
    $ docker build -f src/main/docker/Dockerfile.native -t quarkus-jms-sender .
    [Docker output]
    $ kubectl apply -f kubernetes.yml
    service/quarkus-jms-sender created
    deployment.apps/quarkus-jms-sender created
  6. Change directory to the receiver application, create a deployment, and expose it as a service:

    $ cd ../receiver/
    $ docker build -f src/main/docker/Dockerfile.native -t quarkus-jms-receiver .
    [Docker output]
    $ kubectl apply -f kubernetes.yml
    service/quarkus-jms-receiver created
    deployment.apps/quarkus-jms-receiver created
  7. Check that the deployments and pods are present. You should see deployments and services for broker, sender, and receiver.

    $ kubectl get deployment
    $ kubectl get service
  8. Save the NodePort URLs in local variables:

    $ sender_url=$(minikube service quarkus-jms-sender --url)
    $ receiver_url=$(minikube service quarkus-jms-receiver --url)
  9. Use curl to test the readiness of the send and receive services:

    $ curl $sender_url/health/ready
    {
     "status": "UP",
     "checks": [
    ]
    
    $ curl $receiver_url/health/ready
    {
     "status": "UP",
     "checks": [
    ]
  10. Use curl to send strings to the sender service:

    $ curl -X POST -H "content-type: text/plain" -d hello1 $sender_url/api/send
    OK
    $ curl -X POST -H "content-type: text/plain" -d hello2 $sender_url/api/send
    OK
    $ curl -X POST -H "content-type: text/plain" -d hello3 $sender_url/api/send
    OK
  11. Use curl to receive the sent strings back from the receiver service:

    $ curl $receiver_url/api/receive
    hello1
    $ curl $receiver_url/api/receive
    hello2
    $ curl $receiver_url/api/receive
    hello3

More resources

About

Hello World example using Quarkus Qpid JMS running in Kubernetes

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published