1 Star 0 Fork 0

zhzhouq9/rabbitmq-tutorials

Create your Gitee Account
Explore and code with more than 14 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
receive_logs_topic.rb 736 Bytes
Copy Edit Raw Blame History
Michael Klishin authored 2019-02-27 09:38 +08:00 . Bunny: warn against subscribe(block: true)
#!/usr/bin/env ruby
require 'bunny'
abort "Usage: #{$PROGRAM_NAME} [binding key]" if ARGV.empty?
connection = Bunny.new(automatically_recover: false)
connection.start
channel = connection.create_channel
exchange = channel.topic('topic_logs')
queue = channel.queue('', exclusive: true)
ARGV.each do |severity|
queue.bind(exchange, routing_key: severity)
end
puts ' [*] Waiting for logs. To exit press CTRL+C'
begin
# block: true is only used to keep the main thread
# alive. Please avoid using it in real world applications.
queue.subscribe(block: true) do |delivery_info, _properties, body|
puts " [x] #{delivery_info.routing_key}:#{body}"
end
rescue Interrupt => _
channel.close
connection.close
exit(0)
end
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/zhzhouq9/rabbitmq-tutorials.git
git@gitee.com:zhzhouq9/rabbitmq-tutorials.git
zhzhouq9
rabbitmq-tutorials
rabbitmq-tutorials
master

Search