This is an example application which uses:
- Karafka framework
2.0
to receive messages from Apache Kafka server - WaterDrop gem to send messages back to Kafka
- Karafka-Testing provides RSpec helpers, to make testing of Karafka consumers much easier
- Ruby on Rails ActiveJob to create user instance in the background
It allows you to see how Karafka integrates with Ruby on Rails. Each time you visit localhost:3000
an event will be dispatched to Kafka. This event will be then consumed and stored using Karafka consumer.
This app also includes ActiveJob
job that creates a visitor instance via ActiveJob by using Karafka backend.
Note, that the consumer elevates the #insert_all
from ActiveRecord to insert data efficiently.
- Install all the dependencies by running
bundle install
- Install frontend dependencies by running
yarn install
- Create your SQLite database by running:
bundle exec rake db:create
- Setup your SQLite database structure by running:
bundle exec rails db:migrate
- Setup your test database by running:
bundle exec rake db:test:prepare
- Run
bundle exec rails server
to start the Rails web server - Run
bundle exec karafka server
to start Karafka consumption server - Visit
localhost:3000
and refresh the page couple of times
You can also run RSpec specs to see how the testing RSpec library integrates with Rails:
bundle exec rspec spec