You are viewing documentation for an older version of Lenses.io View latest documentation here

Java topology SDK

Topology client can register your JVM application with Lenses and make them available in the topology.

Including in your project 

The topology client is available on maven central. You will require at least the core builder, which is used for submitting topologies. Users of maven can use the following coordinates:

For an application using Kafka 2.3 or later use this dependency:


For an application using Kafka 2.3 and earlier versions use the following:


Submitting the topology 

To submit the topology to Lenses, we must create an instance of the TopologyClient. To do this, we use the static build method on the KafkaTopologyClient class that requires typical Kafka producer properties. This particular implementation sends the topologies via Kafka topics for persistence:

Properties topologyProps = new Properties();
topologyProps.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092");
/* If you want to override/customize the topology topics, set the appropriate configs

topologyProps.put("lenses.topics.topology", "__topology");
topologyProps.put("lenses.topics.external.metrics", "__topology__metrics");

TopologyClient client = KafkaTopologyClient.create(topologyProps);

After submission, the Lenses UI will display the topology. In the following screenshot you can see three topologies that have been submitted, each one reading from a shared input topic but writing to an individual output topic:

To remove a topology - usually once the stream has been closed or the app terminated - we can use the delete() method on the client: