@resonatehq/kafka is the official Kafka transport binding for the Resonate TypeScript SDK. It replaces the default HTTP transport, routing task invocations and resumptions through Kafka topics instead.
npm install @resonatehq/kafkaPass a Kafka transport instance when constructing Resonate:
import { type Context, Resonate } from "@resonatehq/sdk";
import { Kafka } from "@resonatehq/kafka";
const transport = new Kafka({ brokers: ["localhost:9092"] });
await transport.start();
const resonate = new Resonate({ transport });
resonate.register("foo", function* foo(ctx: Context): Generator {
return yield* ctx.rpc("bar");
});
resonate.register("bar", function bar(_ctx: Context) {
return "hello world";
});
const result = await resonate.run("foo.1", "foo");
console.log(result); // "hello world"
await resonate.stop();Before running, create the required Kafka topics:
resonate
default
Start the Resonate server with Kafka enabled:
resonate dev --api-kafka-enable --aio-kafka-enableThen run your application:
npx ts-node app.tsFull documentation: docs.resonatehq.io