Skip to Content
Topics & MessagingTopics & Event Sources

KalamDB Topics and Messaging

Route KalamDB row changes into a durable topic so a background worker can process them independently of the user interface.

Publish KalamDB table changes

After creating the todo table, run:

SQL
CREATE TOPIC app.todo_events PARTITIONS 1; ALTER TOPIC app.todo_eventsADD SOURCE app.todosON INSERTWITH (payload = 'full'); INSERT INTO app.todos (title) VALUES ('Process this task in a worker');

The insert creates a topic message containing the row payload. Start with one partition; check the reference before choosing another partition count.

Process and acknowledge

Follow the TypeScript consumer guide to connect a consumer group and receive the message. Save the work’s result before acknowledging the message. Make processing safe to retry because a worker can restart after saving the result and before its acknowledgement reaches the server.

For a complete application, run the summarizer agent example, or use a topic-triggered procedure when the handler belongs inside KalamDB.

Common mistakes

A live subscription updates a screen; it does not replace a durable worker acknowledgement. For a USER table source, preserve the producing user’s identity when writing results back. Do not assume a worker’s own user scope contains the producer’s rows.

Next step

Build the AI chat application →

Reference: Topics, sources and consumer operations.