Getting Started with WaterDrop¶
Use Karafka to Both Produce and Consume
If you want to both produce and consume messages, use Karafka. It integrates WaterDrop automatically.
To get started with WaterDrop:
-
Add it to your Gemfile:
bundle add waterdrop -
Create and configure a producer:
producer = WaterDrop::Producer.new do |config| config.deliver = true config.kafka = { 'bootstrap.servers': 'localhost:9092', 'request.required.acks': 1 } end -
Use it as follows:
# And use it producer.produce_sync(topic: 'my-topic', payload: 'my message') # or for async producer.produce_async(topic: 'my-topic', payload: 'my message') # or in batches producer.produce_many_sync( [ { topic: 'my-topic', payload: 'my message'}, { topic: 'my-topic', payload: 'my message'} ] ) # both sync and async producer.produce_many_async( [ { topic: 'my-topic', payload: 'my message'}, { topic: 'my-topic', payload: 'my message'} ] )
More Examples in the Usage Section
For additional WaterDrop usage examples, refer to the Usage section of this documentation.
See Also¶
- WaterDrop About - Introduction and overview of WaterDrop producer
- WaterDrop Usage - Detailed usage patterns and examples
- Producing Messages - Complete guide to producing messages with Karafka
- WaterDrop Configuration - Comprehensive configuration options for WaterDrop
Last modified: 2026-07-24 11:45:41