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.
-
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.
Deploy AMQ broker:
oc apply -f ./service.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-queueDeploy frontend:
oc apply -f ./frontend/.openshiftio/application.yaml
oc new-app --template=spring-boot-messaging-work-queue-frontend \
-p SOURCE_REPOSITORY_URL=https://github.com/snowdrop/messaging-work-queue-example \
-p SOURCE_REPOSITORY_REF=master \
-p SOURCE_REPOSITORY_DIR=frontendDeploy worker:
oc apply -f ./worker/.openshiftio/application.yaml
oc new-app --template=spring-boot-messaging-work-queue-worker \
-p SOURCE_REPOSITORY_URL=https://github.com/snowdrop/messaging-work-queue-example \
-p SOURCE_REPOSITORY_REF=master \
-p SOURCE_REPOSITORY_DIR=workerRun the following commands to configure and deploy the applications.
oc apply -f ./service.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
./mvnw clean fabric8:deploy -PopenshiftNote: integration tests are executed on a current namespace, so make sure to not run them in a production environment. Tests will deploy their own broker which might override the existing one.
To execute the tests run the following command:
./mvnw clean verify -Popenshift,openshift-it