Kafka+Pulsar Shared Topics

When using String or byte schema, it’s possible to share topics between Kafka and Pulsar Producers and Consumers.

Let’s demonstrate this! This will also give us a chance to introduce you to the Pulsar Java Client.

The example uses the following code:

  • KSN-Training/src/main/java/sn_training/SharedTopic/KProducer.java
  • KSN-Training/src/main/java/sn_training/SharedTopic/KConsumer.java
  • KSN-Training/src/main/java/sn_training/SharedTopic/PulsarProducer.java
  • KSN-Training/src/main/java/sn_training/SharedTopic/PulsarConsumer.java
  • KSN-Training/src/main/java/sn_training/resources/client.properties.sharedtopic

For an example configuring the schema connection using a JWT Token or OAuth2 directly in the Java code, see SharedTopicV2.

Update client.properties.sharedtopic so topic1 uses the tenant created for your student id. You will also need to update sasl.jaas.config to use your JWT Token.

The PulsarProducer and PulsarConsumer each need two updates:

  • edit the credentialsUrl to point to your OAuth2 json file in the resources folder.
  • edit the topic to use the student id in the tenant