Giter VIP home page Giter VIP logo

kafka-offset-demo's Introduction

๐Ÿƒ Kafka Offset Demo ๐Ÿƒ

Demo showing how Kafka users can manually set the offset of the next consumed message with a call to the query procedure.

๐Ÿ“‘ Instructions

Place yourself in the root folder and start Zookeeper, Kafka and Memgraph by running:

docker-compose build
docker-compose up core

After that, run the Kafka producer:

docker-compose up kafka-producer

Now open Memgraph Lab, create and start stream:

CREATE KAFKA STREAM sales_stream TOPICS sales TRANSFORM kafkaoffset.sales;
START STREAM sales_stream;

You'll notice how nodes are being created in the Overview tab. Feel free to check out how the created nodes look like with query:

MATCH (n)
RETURN n
LIMIT 10;

Next, stop the stream:

STOP STREAM sales_stream;

Let's say you deleted all of your nodes in the database with:

MATCH (n)
DETACH DELETE n;

If you start the stream again, the last committed offset will be retrieved from the Kafka cluster. This means that you won't get all messages from the stream, but the ones starting from the last committed offset. New Memgraph feature is that you can change that easily and quickly by running:

CALL mg.kafka_set_stream_offset("sales_stream", -1);

After that, when you start your stream again, the consumed messages will be from the beginning of the stream. You'll notice the jump in the number of your nodes in the Overview tab, since all queries from consumed messages from before will be quickly run.

If you want to continue where the last committed offset is, stop the stream, and run:

CALL mg.kafka_set_stream_offset("sales_stream", -2);

To make sure that only new messages are being consumed, again delete everything in your database and start the stream. Then you can notice that the number of nodes in the Overview tab is slowly growing from zero.

๐Ÿ“œ References

For more information about this new feature, check out our docs.

kafka-offset-demo's People

Contributors

katarinasupe avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Forkers

g-despot

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.