This mission example demonstrates how to dispatch tasks to a scalable set of worker processes using a message queue. It uses the AMQP 1.0 message protocol to send and receive messages.
-
JDK 11+ installed with JAVA_HOME configured appropriately
-
The user has access to an OpenShift instance and is logged in.
-
The user has selected a project in which the frontend and backend processes will be deployed.
The frontend
module serves the web interface and communicates with
workers in the backend.
The worker
module implements the worker service in the backend.
Run the following commands to configure and deploy the applications.
oc apply -f .openshiftio/amq.yaml
oc new-app --template=amq-broker-72-basic \
-p APPLICATION_NAME=work-queue-broker \
-p IMAGE_STREAM_NAMESPACE=$(oc project -q) \
-p AMQ_NAME=work-queue-broker \
-p AMQ_PROTOCOL=amqp \
-p AMQ_USER=work-queue \
-p AMQ_PASSWORD=work-queue
Deploy frontend:
./mvnw clean verify -pl frontend -Popenshift -Ddekorate.deploy=true
Deploy worker:
./mvnw clean verify -pl worker -Popenshift -Ddekorate.deploy=true
First, make sure you have installed the Helm command line and connected/logged to a kubernetes cluster.
Then, you need to install the example by doing:
helm install messaging ./helm --set frontend.route.expose=true --set frontend.s2i.source.repo=https://github.com/snowdrop/messaging-work-queue-example --set frontend.s2i.source.ref=<branch-to-use> --set worker.route.expose=true --set worker.s2i.source.repo=https://github.com/snowdrop/messaging-work-queue-example --set worker.s2i.source.ref=<branch-to-use>
note: Replace <branch-to-use>
with one branch from https://github.com/snowdrop/messaging-work-queue-example/branches/all
.
And to uninstall the chart, execute:
helm uninstall messaging
Requirements: - Have installed [the Helm command line](https://helm.sh/docs/intro/install/) - Have connected/logged to a kubernetes cluster
You need to install the example by doing:
helm install messaging ./helm --set worker.ingress.host=<your k8s domain> --set frontend.ingress.host=<your k8s domain>
note: Replace <branch-to-use>
with one branch from https://github.com/snowdrop/messaging-work-queue-example/branches/all
.
And to uninstall the chart, execute:
helm uninstall messaging
Note: integration tests are executed on a current namespace, so make sure to not run them in a production environment.
To execute the tests run the following command:
./run_tests_with_dekorate_in_ocp.sh
./run_tests_with_s2i.sh
This script can take 2 parameters referring to the repository and the branch to use to source the images from.
./run_tests_with_s2i.sh "https://github.com/snowdrop/messaging-work-queue-example" branch-to-test
./run_tests_with_helm_in_ocp.sh
This script can take 2 parameters referring to the repository and the branch to use to source the images from.
./run_tests_with_helm_in_ocp.sh "https://github.com/snowdrop/messaging-work-queue-example" branch-to-test
First, you need to create the k8s namespace:
kubectl create namespace <the k8s namespace>
Then, run the tests by specifying the container registry and the kubernetes namespace:
./run_tests_with_helm_in_k8s.sh <your container registry: for example "quay.io/user"> <the k8s namespace>
For example:
./run_tests_with_helm_in_k8s.sh "quay.io/user" "myNamespace"