@@ -50,14 +50,14 @@ await db.commit(); // 💥 Fails! Message is in queue but no user record
5050
5151## Features
5252
53- ✅ ** At-least-once delivery** - Events are never lost, even during failures or crashes
54- ✅ ** Graceful shutdown** - Finish processing in-flight events before shutting down
55- ✅ ** Horizontal scalability** - Run multiple processors without conflicts using row-level locking
56- ✅ ** Database agnostic** - Built-in support for PostgreSQL and MongoDB, or implement your own
57- ✅ ** Configurable error handling** - Exponential backoff, max retries, and custom error hooks
58- ✅ ** TypeScript-first** - Full type safety and autocompletion
59- ✅ ** Handler result tracking** - Track the execution status of each handler independently
60- ✅ ** Minimal dependencies** - Only ` p-limit ` and ` retry ` (plus your database driver)
53+ - ✅ ** At-least-once delivery** - Events are never lost, even during failures or crashes
54+ - ✅ ** Graceful shutdown** - Finish processing in-flight events before shutting down
55+ - ✅ ** Horizontal scalability** - Run multiple processors without conflicts using row-level locking
56+ - ✅ ** Database agnostic** - Built-in support for PostgreSQL and MongoDB, or implement your own
57+ - ✅ ** Configurable error handling** - Exponential backoff, max retries, and custom error hooks
58+ - ✅ ** TypeScript-first** - Full type safety and autocompletion
59+ - ✅ ** Handler result tracking** - Track the execution status of each handler independently
60+ - ✅ ** Minimal dependencies** - Only ` p-limit ` and ` retry ` (plus your database driver)
6161
6262## Quick Start
6363
@@ -791,15 +791,13 @@ const processor = EventProcessor(createProcessorClient(client), {
791791 UserCreated: {
792792 // Publish to Kafka with guaranteed consistency
793793 publishToKafka : async (event ) => {
794- // Check if already published (idempotency)
795- const published = await checkIfPublished (event .id );
796- if (published ) return ;
797-
794+ // Kafka's idempotent producer handles deduplication
795+ // Using event.id as the key ensures retries are safe
798796 await producer .send ({
799797 topic: " user-events" ,
800798 messages: [
801799 {
802- key: event .data . userId ,
800+ key: event .id , // Use event.id for idempotency
803801 value: JSON .stringify ({
804802 type: event .type ,
805803 data: event .data ,
@@ -808,8 +806,6 @@ const processor = EventProcessor(createProcessorClient(client), {
808806 },
809807 ],
810808 });
811-
812- await markAsPublished (event .id );
813809 },
814810
815811 // Also handle other side effects
0 commit comments