Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.2.1 #23

Merged
merged 1 commit into from
Jan 8, 2025
Merged

1.2.1 #23

merged 1 commit into from
Jan 8, 2025

Conversation

inaiat
Copy link
Owner

@inaiat inaiat commented Jan 8, 2025

Title

feat: add example for consumer events and shutdown handling

Description

This PR adds an example demonstrating proper event handling and graceful shutdown for Kafka consumers.

Changes

  • Add examples/events.mjs showing:
    • Event subscription (onEvents)
    • Message processing
    • Graceful shutdown handling
    • Error handling
  • Update README.md with event handling example section

Example Added

const consumer = new KafkaConsumer({
  brokers: ['localhost:9092'],
  groupId: 'test-group', 
});

// Event handling
consumer.onEvents((err, event) => {
  console.log('Event:', event.name, event.payload);
});

// Graceful shutdown
process.on('SIGINT', async () => {
  await consumer.unsubscribe();
  await consumer.shutdownConsumer();
});

Testing Done
Verified event emission for:
Rebalancing
Commits
Consumer shutdown
Tested graceful shutdown behavior
Confirmed proper cleanup of resources

@inaiat inaiat merged commit 7b67ca5 into main Jan 8, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant