kafka_poll()

Read(602) 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, which is unique across the entire Kafka cluster. The function traverses all partitions in the topic when parameter partition is absent; and must retain parameter timeout when it is present.

Parameters:

fd

A Consumer object

timeout

The interval of consumer poll loop; default is 1000ms

partition

A Kafka topic partition in the cluster mode, which is an integer or an array of integers

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)

Get records from topictest with cursor

4

=kafka_open@c(file("D://kafka.properties");"topic-test")

Connect to Kafka server in cluster mode

5

=kafka_poll(A4)

Traverse all partitiions in the current topic as parameter partition is absent

6

=kafka_poll(A4,1000,1)

Get records in partition 1 in topic-test

7

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

Get records in partitions 1 and 2 in topic-test