Available
amalgame-kafka
Apache Kafka via librdkafka. Producer + Consumer + groups.
Overview
The package links to librdkafka, the reference Kafka C client, which must be installed on the machine. It works with brokers reachable without TLS or SASL: Apache Kafka, Redpanda, Confluent Platform.
Features
- ✓Producer:
Send(key, value, partition) andFlush - ✓Group consumer, manual offset commit (
CommitSync) - ✓One topic per subscription
- ✓Needs
librdkafka-devto build,librdkafka1to run (Debian, Ubuntu)
Planned for v2: TLS and SASL, several topics per subscription, transactions, record headers.
Example
Minimal usage example — copy-paste runnable after install.
amc package add kafka
import Amalgame.Messaging.Kafka
public class Program {
public static void Main(string[] args) {
let p = Kafka.ProducerNew("broker1:9092,broker2:9092")
Kafka.Send(p, "user-events", "user-42", "login", 0 - 1)
Kafka.Flush(p, 5000)
Kafka.ProducerClose(p)
let c = Kafka.ConsumerNew("broker1:9092,broker2:9092", "my-group")
Kafka.Subscribe(c, "user-events")
if (Kafka.Poll(c, 5000)) {
Console.WriteLine(Kafka.LastTopic(c) + "/" + Kafka.LastKey(c) + " = " + Kafka.LastValue(c))
Kafka.CommitSync(c)
}
Kafka.ConsumerClose(c)
}
}
At a glance
- License: Apache-2.0
- Install:
amc package add kafka - Source: amalgame-lang/amalgame-messaging-kafka
- Official index: amalgame-lang/packages-index