Kafka

KafkaSpout API

KafkaSpout API

 

KafkaSpout is a spout implementation that integrates with Storm and can read from Kafka clusters and then emit those messages as tuples within the Storm ecosystem. Here’s a sample code to create a simple KafkaSpout -

 

// ZooKeeper connection string

BrokerHosts hosts = new ZkHosts(zkConnString);

 

//Creating SpoutConfig Object

SpoutConfig spoutConfig = new SpoutConfig(hosts, 

   topicName, "/" + topicName UUID.randomUUID().toString());

 

//convert the ByteBuffer to String.

spoutConfig.scheme = new SchemeAsMultiScheme(new StringScheme());

 

//Assign SpoutConfig to KafkaSpout.

KafkaSpout kafkaSpout = new KafkaSpout(spoutConfig);

 

Top course recommendations for you

    PyTest Basics
    2 hrs
    Beginner
    2.8K+ Learners
    4.42  (146)
    Python MySQL
    1 hrs
    Beginner
    12.4K+ Learners
    4.46  (595)
    Python Automation Project
    2 hrs
    Beginner
    7.1K+ Learners
    4.57  (243)
    Python For Android
    2 hrs
    Beginner
    5.4K+ Learners
    4.51  (144)
    Kivy Projects
    2 hrs
    Beginner
    1.9K+ Learners
    4.5  (56)
    Regex in Python
    1 hrs
    Beginner
    2.9K+ Learners
    4.52  (304)
    Heap Sort Program in C
    1 hrs
    Beginner
    1.3K+ Learners
    4.45  (40)
    Merge Sort Algorithm Using Java
    1 hrs
    Beginner
    1.2K+ Learners
    4.67  (27)