Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'amqp'
- AMQP.start(host: 'localhost', port: 5672) do |connection|
- channel = AMQP::Channel.new(connection)
- exchange = channel.topic("events")
- # the first subscriber will declare a different queue name than the second
- # but will use the same routing key
- channel.queue("service1.usermanager.user.login").bind(exchange, :routing_key => "usermanager.user.login").subscribe do |metadata, payload|
- puts "Subscriber 1: An update for Service 1: #{payload}, routing key is #{metadata.routing_key}"
- end
- show_stopper = Proc.new { puts 'closing the rabbit hole'; connection.close { EventMachine.stop } }
- ['TERM'].each do |sig|
- Signal.trap sig, show_stopper
- end
- end
Add Comment
Please, Sign In to add comment