Menu Close

Chapter 17. Implementing the HA CEP server with a Maven repository for updating the KJAR service

You can implement the HA CEP server that retrieves the KJAR service and all dependencies from a Maven repository that you provide. In this case, you can update the KJAR service at any time by updating it in the Maven repository and then making a call from the client code.

Prepare the source, build it, and then deploy it on Red Hat OpenShift Container Platform. Set certain environment variables in the deployment.yaml file before deploying the server. To use a Maven repository, you must set the UPDATABLEKJAR variable to true.


  • You are logged into the project with administrator privilege using the oc command-line tool.
  • You configured a Maven repository that is accessible from your Red Hat OpenShift Container Platform environment.


  1. Download the 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 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

    Upload the resulting KJAR and any required dependencies to the Maven repository.

  6. Enable the OpenShift operator for Red Hat AMQ Streams and then create an AMQ Streams (kafka) cluster in the project. For information about installing Red Hat AMQ Streams, see Using AMQ Streams on OpenShift.
  7. To create the kafka topics that are required for operation of the server, remain in the openshift-drools-hacep-distribution/sources directory and run the following commands:

    oc apply -f kafka-topics/control.yaml
    oc apply -f kafka-topics/events.yaml
    oc apply -f kafka-topics/kiesessioninfos.yaml
    oc apply -f kafka-topics/snapshot.yaml
  8. In order to enable application access to the ConfigMap that is used in the leader election, 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 pom.xml file to remove the following dependency:

  10. In the springboot directory, enter the following commands to create the image for deployment and push it into the repository configured for your OpenShift environment:

    oc new-build --binary --strategy=docker --name openshift-kie-springboot
    oc start-build openshift-kie-springboot --from-dir=. --follow
  11. Enter the following command to detect the name of the image that was built:

    oc get is/openshift-kie-springboot -o template --template='{{range .status.tags}}{{range .items}}{{.dockerImageReference}}{{end}}{{end}}'
  12. Open the kubernetes/deployment.yaml file in a text editor.
  13. Replace the existing image URL with the result of the previous command.
  14. Remove all characters at the end of the line starting with the @ symbol, then add :latest to the line. For example:

    image: image-registry.openshift-image-registry.svc:5000/hacep/openshift-kie-springboot:latest
  15. Under the containers: line and the env: line, set environment variables as in the following example:

      - env:
        - name: UPDATABLEKJAR
          value: "true"
        - name: KJARGAV
          value: <GroupID>:<ArtifactID>:<Version>
        - name: MAVEN_LOCAL_REPO
          value: /app/.m2/repository
        - name: MAVEN_MIRROR_URL
          value: http://<nexus_url>/repository/maven-releases/
        - name: MAVEN_SETTINGS_XML
          value: /app/.m2/settings.xml

    In this example, replace the value of the KJARGAV variable with the group, artifact, and version (GAV) of your KJAR service and the value of the MAVEN_MIRROR_URL variable with the URL to the Maven repository that contains your KJAR service.

    Optionally, set other variables. For a list of supported environment variables, see Section 17.1, “Optional environment variables supported by the HA CEP server”.

  16. Save the file.
  17. Enter the following command to deploy the image:

    oc apply -f kubernetes/deployment.yaml

For instructions about triggering a KJAR update from the client code, see Chapter 18, Creating the HA CEP client.

17.1. Optional environment variables supported by the HA CEP server

The following table lists optional environment variables that you can set for an HA CEP server that is configured to use a Maven repository. Add these variables to the deployment.yaml file to set them at deployment time.


To use a Maven repository, ensure that you set the UPDATABLEKJAR and KJARGAV environment variables for the server, as described in Chapter 17, Implementing the HA CEP server with a Maven repository for updating the KJAR service.

Table 17.1. Optional environment variables supported by the HA CEP server



Directory to use as the local Maven repository.



The base URL of a Maven mirror that can be used for retrieving artifacts.


If set, multi-mirror support is enabled. The value contains a list of mirror prefixes, divided by commas. If this variable is set, the names of other MAVEN_MIRROR_* variables must contain a prefix, for example, DEV_MAVEN_MIRROR_URL and QE_MAVEN_MIRROR_URL



If set, multi-repo support is enabled. The value contains a list of repo prefixes, divided by commas. If this variable is set, the names of other MAVEN_REPO_* variables must contain a prefix, for example, DEV_MAVEN_REPO_URL and QE_MAVEN_REPO_URL.



The location of a custom Maven settings.xml file to use



Identifier to be used for the specified mirror. If omitted, a unique ID is generated.



Repository IDs mirrored by this mirror. Defaults to external:*



The URL of the mirror


Maven repository host name


Maven repository ID



Maven repository layout



Maven repository username



Maven repository passphrase



Maven repository password



Maven repository path



Maven repository port



Local path to a private key for connecting to the Maven repository



Maven repository protocol



Maven repository releases enabled



Maven repository releases update policy



Maven repository OpenShift service. This value is used if a URL or host/port/protocol is not specified.



Maven repository snapshots enabled



Maven repository snapshots update policy



Fully qualified URL for the Maven repository