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
-
Download the
rhpam-7.5.1-reference-implementation.zip
product deliverable file from the Software Downloads page of the Red Hat Customer Portal. -
Extract the contents of the file and then uncompress the
rhpam-7.5.1-openshift-drools-hacep-distribution.zip
file. -
Change to the
openshift-drools-hacep-distribution/sources
directory. -
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 thesrc/main/resources/org.drools.cep
subdirectory. Build the project using the standard Maven command:
mvn clean install -DskipTests
- 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.
Using the
KafkaTopic
resource on Red Hat OpenShift Container Platform, create the topics from all the YAML files in thekafka-topics
subdirectory.For instructions about creating topics using the
KafkaTopic
resource, see Using the topic operator in the Red Hat AMQ documentation.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.
In the
springboot
directory, edit theDockerfile
file. Replace the line that contains themicrodnf
command with the following line:RUN microdnf install java-1.8.0-openjdk-headless && microdnf clean all
NoteThis workaround is required because of a recently found issue with microdnf.
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 builtsample-hacep-project-kjar
code as a Maven dependency and includes it in theBOOT-INF/lib
directory of theopenshift-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
withpodman
in the commands.-
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.