#!/usr/bin/env python
import threading, logging, time

from kafka.client import KafkaClient
from kafka.consumer import SimpleConsumer
from kafka.producer import SimpleProducer

class Producer(threading.Thread):
    daemon = True

    def run(self):
        client = KafkaClient("localhost:9092")
        producer = SimpleProducer(client)

        while True:
            producer.send_messages('my-topic', "test")
            producer.send_messages('my-topic', "\xc2Hola, mundo!")

            time.sleep(1)


class Consumer(threading.Thread):
    daemon = True

    def run(self):
        client = KafkaClient("localhost:9092")
        consumer = SimpleConsumer(client, "test-group", "my-topic")

        for message in consumer:
            print(message)

def main():
    threads = [
        Producer(),
        Consumer()
    ]

    for t in threads:
        t.start()

    time.sleep(5)

if __name__ == "__main__":
    logging.basicConfig(
        format='%(asctime)s.%(msecs)s:%(name)s:%(thread)d:%(levelname)s:%(process)d:%(message)s',
        level=logging.DEBUG
        )
    main()

@@ -62,15 +62,8 @@
 afka
-.client
  imp
@@ -76,89 +76,22 @@
 fkaC
-lient%0Afrom kafka.consumer import SimpleConsumer%0Afrom kafka.producer import Simple
+onsumer, Kafka
 Prod
@@ -96,16 +96,17 @@
 oducer%0A%0A
+%0A
 class Pr
@@ -181,87 +181,67 @@
     
-client = KafkaClient(%22localhost:9092%22)%0A        producer = SimpleProducer(client
+producer = KafkaProducer(bootstrap_servers='localhost:9092'
 )%0A%0A 
@@ -280,33 +280,24 @@
 roducer.send
-_messages
 ('my-topic',
@@ -297,16 +297,17 @@
 topic', 
+b
 %22test%22)%0A
@@ -335,17 +335,8 @@
 send
-_messages
 ('my
@@ -344,16 +344,17 @@
 topic', 
+b
 %22%5Cxc2Hol
@@ -365,17 +365,16 @@
 undo!%22)%0A
-%0A
         
@@ -474,21 +474,23 @@
        c
-lient
+onsumer
  = Kafka
@@ -494,15 +494,35 @@
 fkaC
-lient(%22
+onsumer(bootstrap_servers='
 loca
@@ -531,18 +531,18 @@
 ost:9092
-%22)
+',
 %0A       
@@ -546,65 +546,100 @@
     
-consumer = SimpleConsumer(client, %22test-group%22, %22
+                         auto_offset_reset='earliest')%0A        consumer.subscribe(%5B'
 my-topic
 %22)%0A%0A
@@ -634,17 +634,18 @@
 my-topic
-%22
+'%5D
 )%0A%0A     
@@ -689,16 +689,17 @@
    print
+ 
 (message
@@ -701,16 +701,17 @@
 ssage)%0A%0A
+%0A
 def main
@@ -836,9 +836,10 @@
 eep(
-5
+10
 )%0A%0Ai
@@ -1013,13 +1013,12 @@
 ing.
-DEBUG
+INFO
 %0A   

Use KafkaProducer / KafkaConsumer in example.py