|
|
|
@ -8,11 +8,11 @@ module Sylvilagus::Ch02::HelloWorld
|
|
|
|
|
module ClassMethods
|
|
|
|
|
def with_hello_world_conn(&block)
|
|
|
|
|
factory = ConnectionFactory.new
|
|
|
|
|
factory.setUri('amqp://guest:guest@localhost:5672')
|
|
|
|
|
conn = factory.newConnection
|
|
|
|
|
channel = conn.createChannel
|
|
|
|
|
channel.exchangeDeclare('hello-exchange', 'direct', true)
|
|
|
|
|
channel.queueDeclare('hello-queue', false, false, false, nil)
|
|
|
|
|
factory.uri = 'amqp://guest:guest@localhost:5672'
|
|
|
|
|
conn = factory.new_connection
|
|
|
|
|
channel = conn.create_channel
|
|
|
|
|
channel.exchange_declare('hello-exchange', 'direct', true)
|
|
|
|
|
channel.queue_declare('hello-queue', false, false, false, nil)
|
|
|
|
|
|
|
|
|
|
block.call(conn, channel)
|
|
|
|
|
ensure
|
|
|
|
|