I've been working with Apache Kafka for over 7 years. I inevitably find myself doing the same set of activities while I'm developing or working with someone else's system. Here's a set of Kafka productivity hacks for doing a few things way faster than you're probably doing them now. 🔥
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"generators": [ | |
{ | |
"table": "posts", | |
"vars": { | |
"delay": { | |
"_gen": "normalDistribution", | |
"mean": 500, | |
"sd": 40 | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"generators": [ | |
{ | |
"connection": "pg", | |
"table": "customers", | |
"row": { | |
"name": { | |
"_gen": "string", | |
"expr": "#{Name.firstName}" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"generators": [ | |
{ | |
"table": "users", | |
"row": { | |
"name": { | |
"_gen": "string", | |
"expr": "#{Name.fullName}" | |
}, | |
"emoji": { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: "2" | |
services: | |
kafka: | |
image: docker.io/bitnami/kafka:3.5 | |
ports: | |
- "9092:9092" | |
volumes: | |
- "kafka_data:/bitnami" | |
environment: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"genvp.m.with" "#{Name.title.job}", | |
"topic.m.records.exactly" "2", | |
"global.matching.rate" "1.0"} | |
=================== | |
{"global.matching.rate" "1.0"} | |
=================== | |
{"genkp.9oU.matching" "u.value", | |
"genk.Eq.2.with" "#{Name.female_first_name}", | |
"genv.Eq.8Q.with" "#{Address.country_code}", | |
"genkp.u.sometimes.matching" "Eq.value.8Q", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Step 1 | |
CREATE STREAM riderLocations | |
(profileId VARCHAR, latitude DOUBLE, longitude DOUBLE, timestamp BIGINT) | |
WITH (kafka_topic='locations', key='profileId', value_format='json', partitions=1, timestamp='timestamp'); | |
-- Step 2 | |
INSERT INTO riderLocations (profileId, latitude, longitude, timestamp) VALUES ('4ab5cbad', 37.3956, -122.0810, 1578528022704); | |
INSERT INTO riderLocations (profileId, latitude, longitude, timestamp) VALUES ('c2309eec', 37.7877, -122.4205, 1578528022805); | |
INSERT INTO riderLocations (profileId, latitude, longitude, timestamp) VALUES ('18f4ea86', 37.3903, -122.0643, 1578528023612); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
version: '2' | |
services: | |
zookeeper: | |
image: confluentinc/cp-zookeeper:5.3.1 | |
hostname: zookeeper | |
container_name: zookeeper | |
ports: | |
- "2181:2181" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package io.confluent.developer; | |
import java.util.List; | |
import java.util.Map; | |
import io.confluent.ksql.function.udaf.Udaf; | |
import io.confluent.ksql.function.udaf.UdafDescription; | |
import io.confluent.ksql.function.udaf.UdafFactory; | |
import io.confluent.ksql.function.udaf.TableUdaf; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
INSERT INTO all_publications (author, title) VALUES ('C.S. Lewis', 'The Silver Chair'); | |
INSERT INTO all_publications (author, title) VALUES ('George R. R. Martin', 'A Song of Ice and Fire'); | |
INSERT INTO all_publications (author, title) VALUES ('C.S. Lewis', 'Perelandra'); | |
INSERT INTO all_publications (author, title) VALUES ('J. R. R. Tolkien', 'The Hobbit'); | |
INSERT INTO all_publications (author, title) VALUES ('J. R. R. Tolkien', 'The Lord of the Rings'); | |
INSERT INTO all_publications (author, title) VALUES ('J. R. R. Tolkien', 'The Fellowship of the Ring'); |