Specifying a custom classpath for Kafka client libraries
You can specify a custom classpath for Kafka client libraries if you need to use a different version of Kafka client or add more libraries to be executed by your Kafka client, such as OAuth and Interceptor handlers.
Procedure
-
Create the
kafka-client-classloader.cpfile in theCDC_Kafka_instance_directory/confdirectory. - Open the file and provide a custom classpath. The format must match your platform. For
example, on Linux you need to provide a colon-separated list:
library1.jar:library2.jar:...:libraryX.jarRestart your CDC Replication Engine for Kafka instance.
Example:- Enabling
OAuthlibraries for IBM event stream -
- Build the necessary Kafka client libraries and
OAuthhandler by using CDC's Java version or earlier. For more details, see IBM event stream sample with Java 8. - Modify
kafkaconsumer.propertiesandkafkaproducer.propertiesin the instanceconfdirectory of CDC to includeOAuthconnection options for the Kafka cluster. Ensure that these parameters are tested by using Apache Kafka consumer or producer.Example:Use the same connection properties forcat <CDC instance dir>/conf/kafkaconsumer.properties bootstrap.servers=<bootstrap servers> sasl.mechanism=OAUTHBEARER sasl.jaas.config=org.apache.kafka.common.security.oauthbearer.OAuthBearerLoginModule required grant_type="urn:ibm:params:oauth:grant-type:apikey" apikey="<api key>"; sasl.login.callback.handler.class=com.ibm.eventstreams.oauth.client.IAMOAuthBearerLoginCallbackHandler sasl.oauthbearer.token.endpoint.url=https://iam.cloud.ibm.com/identity/token sasl.oauthbearer.jwks.endpoint.url=https://iam.cloud.ibm.com/identity/keys security.protocol=SASL_SSL ssl.protocol=TLSv1.2 ssl.enabled.protocols=TLSv1.2 ssl.endpoint.identification.algorithm=HTTPSkafkaproducer.propertiesas well. - In the instance
confdirectory of CDC, create a file that is namedkafka-client-classloader.cp. Include allOAuthhandler andkafka-client libraries/dependenciesin it. Full path names are separated by semicolons.Example:cat <CDC instance dir>/conf/kafka-client-classloader.cp <path>/jackson-annotations-2.14.2.jar:<path>/jackson-databind-2.14.2.jar:<path>kafka-clients-3.3.2.jar:<path>/oauth-client-0.1.2.jar:<path>/slf4j-simple-1.7.36.jar:<path>/zstd-jni-1.5.2-1.jar:<path>/jackson-core-2.14.2.jar:<path>/jose4j-0.9.3.jar:<path>/lz4-java-1.8.0.jar:<path>/slf4j-api-1.7.36.jar:<path>/snappy-java-1.1.8.4.jar - If you enabled a
KCOPto write audit records inAvroformat (see, Enabling a KCOP to write audit records in Avro format), update thekcop.propertiesfile to includeschema.registry.urland allserializer.propertyconnection arguments that start withschema.registry.property. If you include schema registry and Kafka client libraries in the instanceconfdirectoryuser-classloader.cpfile, then also include Kafka client libraries and additional libraries inuser-classloader.cprather thankafka-client-classloader.cp.Example:cat <path>/kcop.properties audit.jcfs=ENTTYP,CCID before.image.prefix=B_ before.update.record.mode=ALWAYS schema.registry.url=<schema registry url> serializer.property.basic.auth.credentials.source=USER_INFO serializer.property.schema.registry.basic.auth.user.info=<user>:<password>Note:To pass serializer properties, use
serializer.property.propertyName. For more details, see Using IBM Event Streams Version 10.To add
OAuthlibraries to connect to the schema registry forAvro KCOP, see Specifying a custom classpath for KCOPs.
- Build the necessary Kafka client libraries and
- Enabling
- Restart your CDC Replication Engine for Kafka instance.