-
Book Overview & Buying
-
Table Of Contents
Mastering RabbitMQ
By :
Let's continue by building a sanity-level consumer and producer just to test things out.
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.closeWe 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 got. We publish through a routing key that incidentally (or not) has the same name as the queue in order to autoroute the message to that queue.
We send a message that looks like JSON, but this is just a hint at what's about to come; for all...
Change the font size
Change margin width
Change background colour