Skip to content

Latest commit

 

History

24 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

@resonatehq/kafka

⚠️ This plugin is paused. It targets the legacy Go-based Resonate Server (which had --api-kafka-enable flags); those flags do not exist in the current Rust-based Resonate Server (v0.9.7+). Do not install this for use against the current server.

What to use instead, today: the Kafka worker pattern — consume Kafka with kafkajs (or confluent-kafka-python, rdkafka for other languages) and call resonate.beginRun(messageId, "workflow", ...) per message. Using the Kafka message ID as the Resonate promise ID gives you idempotent dispatch.

Roadmap: Native kafka:// transport is fully specified and is planned for a future release; the transport section of the spec is not yet public. This plugin will be revived (or replaced) once that lands.

Reference examples for the worker pattern:

@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.

Installation

npm install @resonatehq/kafka

Usage

Pass 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-enable

Then run your application:

npx ts-node app.ts

Examples

Documentation

Full documentation: docs.resonatehq.io

About

The official Kafka transport binding for Resonate.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages