Skip to content

Instantly share code, notes, and snippets.

@chromy96
chromy96 / delete-records.json
Created March 4, 2020 16:36
kafka-delete-records json
{
"partitions": [
{
"topic": "my-topic",
"partition": 0,
"offset": 3
}
],
"version": 1
}

Kafka 0.11.0.0 (Confluent 3.3.0) added support to manipulate offsets for a consumer group via cli kafka-consumer-groups command.

  1. List the topics to which the group is subscribed
kafka-consumer-groups --bootstrap-server <kafkahost:port> --group <group_id> --describe

Note the values under "CURRENT-OFFSET" and "LOG-END-OFFSET". "CURRENT-OFFSET" is the offset where this consumer group is currently at in each of the partitions.

  1. Reset the consumer offset for a topic (preview)
@chromy96
chromy96 / DirectoryWatcherOnDiskTest.java
Created June 20, 2018 12:36
Testing file lock for create
@Test
public void emitCreateEventWhenFileLocked() throws IOException, ExecutionException, InterruptedException {
final CompletableFuture future = this.watcher.watchAsync();
final Path child = Files.createTempFile(tmpDir, "child-", ".dat");
FileChannel channel = null;
FileLock lock = null;
try {
File file = child.toFile();
channel = new RandomAccessFile(file, "rw").getChannel();