kafka_poll()

Read(674) Label: get records, table sequence, cursor,

Description:

Return records in a Consumer topic as a table sequence.

Syntax:

kafka_poll (fd, timeout,[partition1, partition2,]) 

Note:

The external library function gets records of the current Consumer topic. The function traverses all partitions in the topic when parameter partition is absent.

Parameters:

fd

A Consumer object

timeout

The interval of consumer poll loop; default is 1000ms

partition

The number of partitions in a topic, which is an integer or a sequence

Options:

@c

Enable a cursor-based query

Return value:

Table sequence or cursor

Example:

 

A

 

1

=kafka_open("D://kafka.properties","topic-test")

Connect to Kafka server

2

=kafka_poll(A1)

Get records from topictest

3

=kafka_poll@c(A1).fetch()

Get records in the way of cursor

4

=kafka_poll(A1,2000)

 

5

=kafka_open(file("D://kafka.properties"),"topic-test1")

 

6

=kafka_offset(A5,2,0)

Set offset as 2 for records in partition0 in topic-test1

7

=kafka_poll(A5,1000,0)

Get records in partition0

8

=kafka_poll(A5,1000,[1,2])

Get records in partition1 and partition2

9

=kafka_ close(A1))