Permalink
Browse files

Add examples.

  • Loading branch information...
dsully committed Feb 18, 2011
1 parent d0aec11 commit d0a3427ef57b5b90cc8259f002b33f3f2aab60f7
Showing with 38 additions and 0 deletions.
  1. +10 −0 examples/batch
  2. +9 −0 examples/consume-iter
  3. +8 −0 examples/consume-loop
  4. +11 −0 examples/produce
View
@@ -0,0 +1,10 @@
+#!/usr/bin/env python
+
+import kafka
+
+producer = kafka.producer.Producer('test')
+
+with producer.batch() as messages:
+ print "Batching a send of multiple messages.."
+ messages.append(kafka.message.Message("first message to send"))
+ messages.append(kafka.message.Message("second message to send"))
View
@@ -0,0 +1,9 @@
+#!/usr/bin/env python
+
+import kafka.consumer
+
+consumer = kafka.consumer.Consumer('test')
+#messages = consumer.consume()
+
+for message in consumer.loop():
+ print message
View
@@ -0,0 +1,8 @@
+#!/usr/bin/env python
+
+import kafka
+
+consumer = kafka.consumer.Consumer('test')
+
+for message in consumer.consume():
+ print message
View
@@ -0,0 +1,11 @@
+#!/usr/bin/env python
+
+import kafka
+import time
+
+producer = kafka.producer.Producer('test')
+message1 = kafka.message.Message("some random message content?")
+message2 = kafka.message.Message("foo!")
+message3 = kafka.message.Message(time.time())
+
+producer.send([message1, message2, message3])

0 comments on commit d0a3427

Please sign in to comment.