This function creates a KAFKA consumer
rkafka.createConsumer(zookeeperConnect, topicName,
groupId="test-consumer-group", zookeeperConnectionTimeoutMs="100000",
consumerTimeoutMs="10000", autoCommitEnable="NULL",
autoCommitInterval="NULL", autoOffsetReset="NULL")
Returns a consumer
Zookeeper connection string comma separated host:port pairs, each corresponding to a zk server. e.g."127.0.0.1:3000,127.0.0.1:3001,127.0.0.1:3002" Required:Mandatory Type:String default:NONE
Name of the topic from which to read messages Required:Mandatory Type:String
consumer group id Required:Mandatory Type:String default:test-consumer-group
timeout in ms for connecting to zookeeper Required:Mandatory Type:String default:100000
Throw a timeout exception to the consumer if no message is available for consumption after the specified interval Required:Mandatory Type:String default:10000
If true, periodically commit to ZooKeeper the offset of messages already fetched by the consumer. This committed offset will be used when the process fails as the position from which the new consumer will begin. Required:Optional Type:String default:true
The frequency in ms that the consumer offsets are committed to zookeeper. Required:Optional Type:String default:60*1000
smallest : automatically reset the offset to the smallest offset largest : automatically reset the offset to the largest offset anything else: throw exception to the consumer Required:Optional Type:String default:largest
Shruti Gupta
There are two types of KAFKA consumers: High-level and Simple. This functions creates a high level consumer
To know when to use simple consumer and when to use High-level Consumer, refer the url below: https://cwiki.apache.org/confluence/display/KAFKA/0.8.0+SimpleConsumer+Example
To know how to use a high level consumer refer this: https://cwiki.apache.org/confluence/display/KAFKA/Consumer+Group+Example
if (FALSE) {
consumer1=rkafka.createConsumer("127.0.0.1:2181","test123")
consumer2=rkafka.createConsumer("127.0.0.1:2181","test123","test-consumer-group","50000","1000")
}
Run the code above in your browser using DataLab