kafkaproducer
Create a Kafka producer.
Syntax
pobj = kafkaproducer(bootstrap_servers,acks)
pobj = kafkaproducer(bootstrap_servers,acks,[Name, value])
Inputs
- bootstrap_servers
- server address tag
- acks
- acks is the number of brokers who need to acknowledge receiving the message before it is considered a successful write.Valid values are 0, 1 or 'all'.
- Name, value
- Name
Outputs
- pobj
- Kafka consumer object.
- Function Name, Syntax
- Type: string
Examples
Producer creation and sending data
function sendcallback(partition, offset, message)
disp('start of sendcallback')
partition
offset
message
disp('end of sendcallback')
end
%producer sending data
kproduer = kafkaproducer('192.168.40.49', 1);
partitions=kproduer.partitionsfor('compose_topic')
kproduer.send('compose_topic','hello','callback','sendcallback')
kproduer.flush()
kproduer.close()
partitions =
{
[1,1] 0
}
start of sendcallback
partition = 0
offset = 947
message = hello
end of sendcallback