Este conteúdo não está disponível no idioma selecionado.
Chapter 15. Creating the HA CEP client
You must adapt your CEP client code to communicate with the HA CEP server image. Use the sample project included in the reference implementation for your client code. You can run your client code inside or outside the OpenShift environment.
Procedure
-
Download the
rhdm-7.11.0-reference-implementation.zipproduct deliverable file from the Software Downloads page of the Red Hat Customer Portal -
Extract the contents of the file and then uncompress the
rhdm-7.11.0-openshift-drools-hacep-distribution.zipfile. -
Change to the
openshift-drools-hacep-distribution/sourcesdirectory. -
Review and modify the client code based on the sample project in the
sample-hacep-project/sample-hacep-project-clientdirectory. Ensure that the code fulfills the additional requirements described in Chapter 16, Requirements for HA CEP client and server code. To update the KJAR version in an implementation that uses the method described in Chapter 14, Implementing the HA CEP server with a Maven repository for updating the KJAR service, add an
UpdateKJarGAVcall to the client, similar to the following code:TopicsConfig envConfig = TopicsConfig.getDefaultTopicsConfig(); Properties props = getProperties(); try (RemoteStreamingKieSession producer = RemoteStreamingKieSession.create(props, envConfig)){ producer.updateKJarGAV("org.kie:fake-jar:0.1"); }TopicsConfig envConfig = TopicsConfig.getDefaultTopicsConfig(); Properties props = getProperties(); try (RemoteStreamingKieSession producer = RemoteStreamingKieSession.create(props, envConfig)){ producer.updateKJarGAV("org.kie:fake-jar:0.1"); }Copy to Clipboard Copied! Toggle word wrap Toggle overflow Ensure that a KJAR with the specified GAV is available in the Maven repository when this call is executed.
In the
sample-hacep-project/sample-hacep-project-clientdirectory, generate a keystore, usingpasswordas a password. Enter the following command:keytool -genkeypair -keyalg RSA -keystore src/main/resources/keystore.jks
keytool -genkeypair -keyalg RSA -keystore src/main/resources/keystore.jksCopy to Clipboard Copied! Toggle word wrap Toggle overflow Extract the HTTPS certificate from the OpenShift environment and add it to the keystore. Enter the following commands:
oc extract secret/my-cluster-cluster-ca-cert --keys=ca.crt --to=- > src/main/resources/ca.crt keytool -import -trustcacerts -alias root -file src/main/resources/ca.crt -keystore src/main/resources/keystore.jks -storepass password -noprompt
oc extract secret/my-cluster-cluster-ca-cert --keys=ca.crt --to=- > src/main/resources/ca.crt keytool -import -trustcacerts -alias root -file src/main/resources/ca.crt -keystore src/main/resources/keystore.jks -storepass password -nopromptCopy to Clipboard Copied! Toggle word wrap Toggle overflow -
In the
src/main/resourcessubdirectory of the project, open theconfiguration.propertiesfile and replace<bootstrap-hostname>with the address that the route for the Kafka server provides. Build the project using the standard Maven command:
mvn clean install
mvn clean installCopy to Clipboard Copied! Toggle word wrap Toggle overflow Change the
sample-hacep-project-clientproject directory and enter the following command to run the client:mvn exec:java -Dexec.mainClass="org.kie.hacep.sample.client.ClientProducerDemo"
mvn exec:java -Dexec.mainClass="org.kie.hacep.sample.client.ClientProducerDemo"Copy to Clipboard Copied! Toggle word wrap Toggle overflow This command executes the
mainmethod of theClientProducerDemoclass.