Ruby 和 Rails 高效的 Kafka 处理框架
# Define what topics you want to consume with which consumers in karafka.rb
Karafka::App.routes.draw do
topic 'system_events' do
consumer EventsConsumer
end
end
# And create your consumers, within which your messages will be processed
class EventsConsumer < ApplicationConsumer
# Example that utilizes ActiveRecord#insert_all and Karafka batch processing
def consume
# Store all of the incoming Kafka events locally in an efficient way
Event.insert_all messages.payloads
end
end
``` 使用线程在同一个进程中同时处理多个消息。它不需要 Rails,但会与任何基于 Ruby on Rails 的应用程序紧密集成,使事件处理变得简单无比。暂无开放 Issues,或尚未同步最近议题。