6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/asynk/broker.rb', line 6
def connect
@amqp_connection = Bunny.new(host: Asynk.config[:mq_host],
port: Asynk.config[:mq_port],
username: Asynk.config[:mq_username],
password: Asynk.config[:mq_password],
vhost: Asynk.config[:mq_vhost])
Asynk.logger.info [ "Connection to Rabbit with params host: #{Asynk.config[:mq_host]}:#{Asynk.config[:mq_port]}",
"username: '#{Asynk.config[:mq_username]}' ", "vhost: '#{Asynk.config[:mq_vhost]}'"
].join(' ')
@amqp_connection.start
@pool = ConnectionPool.new(size: 10, timeout: 5) do
channel = @amqp_connection.create_channel(nil, nil)
[channel, channel.topic(Asynk.config[:mq_exchange]), channel.queue('', exclusive: true)]
end
end
|