METRON-1573 Enhance KAFKA_* functions to return partition and offset details #1030
Conversation
…object. Now the simple view returns a count of the number of messages written
When I try: [Stellar]>>> KAFKA_PUT("mytopic", "{ message! }") So nothing is pulled back. But the topic and the data does exist: /usr/hdp/current/kafka-broker/bin/kafka-console-consumer.sh --topic mytopic --zookeeper localhost:2181 --from-beginning { message! } |
KAFKA_TAIL always seeks to the end of the topic. So the consumer offset was set to the end of the topic (offset=2) after you call to KAFKA_TAIL. No more messages arrived on this topic, so it timed out and returned no data. If you had run this on a topic actively receiving data, you would have seen the new messages arriving.
KAFKA_GET will always use the existing consumer offset. The offset is at 2 based on the previous call to KAFKA_TAIL. Since there are no messages at offset 2, It didn't return anything. Use KAFKA_TAIL on one of the sensor topics in the dev environment. You will be able to see the latest messages arriving.
You can also manually change your
|
5836fbd
to
530b707
Compare
+1 great work |
This PR is dependent on #1025 and should not be merged until that PR is addressed.
Changes
Implemented multiple 'views' of the messages fetched from Kafka. The "rich" view contains not only the message value, but Kafka metadata like the topic, partition, offset, key, and timestamp.
Updated KAFKA_GET, KAFKA_TAIL, and KAFKA_FIND so that each can optionally return a "rich" view of the messages retrieved from Kafka.
Updated KAFKA_PUT so that it can optionally returns a "rich" view describing the topic, partition, offset, and timestamp of the message that was just put/sent to Kafka.
The change is backwards compatible. By default, only the value (the "simple" view) is returned, just like before.
Demo
By default, only the message value is returned.
Turn on the "rich" view.
Fetch the next message.
Fetch from the tail end of the topic. Notice the offset change.
Put a message onto a topic.
Testing
Launch the dev environment.
Run the Stellar REPL.
Try both the "simple" and "rich" views for each of the functions; KAFKA_GET, KAFKA_TAIL and KAFKA_FIND.
Pull Request Checklist