Chapter 2. Implementing the HA CEP server

The high-availability (HA) CEP server runs on the Red Hat OpenShift Container Platform environment. It includes all necessary Drools rules and other code required to process events.

You must prepare the source, build it, and then deploy it on Red Hat OpenShift Container Platform.

Procedure

  1. Download the rhpam-7.5.1-reference-implementation.zip product deliverable file from the Software Downloads page of the Red Hat Customer Portal.
  2. Extract the contents of the file and then uncompress the rhpam-7.5.1-openshift-drools-hacep-distribution.zip file.
  3. Change to the openshift-drools-hacep-distribution/sources directory.
  4. Review and modify the server code based on the sample project in the sample-hacep-project/sample-hacep-project-kjar directory. The complex event processing logic is defined by the DRL rules in the src/main/resources/org.drools.cep subdirectory.
  5. Build the project using the standard Maven command:

    mvn clean install -DskipTests
  6. Use the OpenShift operator infrastructure to install Red Hat AMQ Streams. For information about installing Red Hat AMQ Streams, see Using AMQ Streams on OpenShift Container Platform.
  7. Using the KafkaTopic resource on Red Hat OpenShift Container Platform, create the topics from all the YAML files in the kafka-topics subdirectory.

    For instructions about creating topics using the KafkaTopic resource, see Using the topic operator in the Red Hat AMQ documentation.

  8. In order to enable application access to the ConfigMap that is used in the leader election, you must configure role-based access control. Change to the springboot directory and enter the following commands:

    oc create -f kubernetes/service-account.yaml
    oc create -f kubernetes/role.yaml
    oc create -f kubernetes/role-binding.yaml

    For more information about configuring role-based access control in Red Hat OpenShift Container Platform, see Using RBAC to define and apply permissions in the Red Hat OpenShift Container Platform product documentation.

  9. In the springboot directory, edit the Dockerfile file. Replace the line that contains the microdnf command with the following line:

    RUN microdnf install java-1.8.0-openjdk-headless && microdnf clean all
    Note

    This workaround is required because of a recently found issue with microdnf.

  10. In the springboot directory, enter the following commands to build the Docker image and push it into the Docker registry that is configured on your system. (Consider configuring a private registry before running these commands). This build imports the built sample-hacep-project-kjar code as a Maven dependency and includes it in the BOOT-INF/lib directory of the openshift-kie-springboot.jar file. The Docker build then uses the JAR file to create the image.

    docker login --username=<user username>
    docker build -t <user_username>/openshift-kie-springboot:<tag> .
    docker push <user_username>/openshift-kie-springboot:<tag>

    Alternatively, to use Podman for the build process, replace docker with podman in the commands.

  11. In the OpenShift user interface, create a YAML source. Paste in the contents of the kubernetes/deployment.yaml and change the Docker image name as necessary. Click Deploy to deploy the server.