Using Bunny
Let's continue by building a sanity-level consumer and producer just to test things out.
Bunny producer
We will first have a taste of what a log aggregator producer looks like:
require "bunny" conn = Bunny.new conn.start channel = conn.create_channel queue = channel.queue("clicks") channel.default_exchange.publish('{ "message":"hello" }', :routing_key => queue.name) puts "* sent!" conn.close
We start inquiring about Bunny so that we have access to the Bunny API. We then initialize a Bunny instance, start a connection for the purpose of getting a reach at an AMQP channel, and then through the channel, we declare a queue and get access to an exchange.
We use the default exchange for simplicity, which was accessed through the channel we just ...
Get Mastering RabbitMQ now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.