@@ -17,9 +17,8 @@ Copyright 2013, David Arthur under Apache License, v2.0. See `LICENSE`
1717
1818# Status
1919
20- I'm following the version numbers of Kafka, plus one number to indicate the
21- version of this project. The current version is 0.8.0-1. This version is under
22- development, APIs are subject to change.
20+ The current version of this package is ** 0.9.0** and is compatible with
21+ Kafka brokers running version ** 0.8.1** .
2322
2423# Usage
2524
@@ -33,24 +32,24 @@ from kafka.producer import SimpleProducer, KeyedProducer
3332kafka = KafkaClient(" localhost:9092" )
3433
3534# To send messages synchronously
36- producer = SimpleProducer(kafka, " my-topic " )
37- producer.send_messages(" some message" )
38- producer.send_messages(" this method" , " is variadic" )
35+ producer = SimpleProducer(kafka)
36+ producer.send_messages(" my-topic " , " some message" )
37+ producer.send_messages(" my-topic " , " this method" , " is variadic" )
3938
4039# To send messages asynchronously
41- producer = SimpleProducer(kafka, " my-topic " , async = True )
42- producer.send_messages(" async message" )
40+ producer = SimpleProducer(kafka, async = True )
41+ producer.send_messages(" my-topic " , " async message" )
4342
4443# To wait for acknowledgements
4544# ACK_AFTER_LOCAL_WRITE : server will wait till the data is written to
4645# a local log before sending response
4746# ACK_AFTER_CLUSTER_COMMIT : server will block until the message is committed
4847# by all in sync replicas before sending a response
49- producer = SimpleProducer(kafka, " my-topic " , async = False ,
48+ producer = SimpleProducer(kafka, async = False ,
5049 req_acks = SimpleProducer.ACK_AFTER_LOCAL_WRITE ,
51- acks_timeout = 2000 )
50+ ack_timeout = 2000 )
5251
53- response = producer.send_messages(" async message" )
52+ response = producer.send_messages(" my-topic " , " async message" )
5453
5554if response:
5655 print (response[0 ].error)
@@ -63,7 +62,7 @@ if response:
6362# Notes:
6463# * If the producer dies before the messages are sent, there will be losses
6564# * Call producer.stop() to send the messages and cleanup
66- producer = SimpleProducer(kafka, " my-topic " , batch_send = True ,
65+ producer = SimpleProducer(kafka, batch_send = True ,
6766 batch_send_every_n = 20 ,
6867 batch_send_every_t = 60 )
6968
@@ -84,11 +83,11 @@ from kafka.partitioner import HashedPartitioner, RoundRobinPartitioner
8483kafka = KafkaClient(" localhost:9092" )
8584
8685# HashedPartitioner is default
87- producer = KeyedProducer(kafka, " my-topic " )
88- producer.send(" key1" , " some message" )
89- producer.send(" key2" , " this methode" )
86+ producer = KeyedProducer(kafka)
87+ producer.send(" my-topic " , " key1" , " some message" )
88+ producer.send(" my-topic " , " key2" , " this methode" )
9089
91- producer = KeyedProducer(kafka, " my-topic " , partitioner = RoundRobinPartitioner)
90+ producer = KeyedProducer(kafka, partitioner = RoundRobinPartitioner)
9291```
9392
9493## Multiprocess consumer
0 commit comments