Sha256: 4474ea98975c5aa4e0e5a4be91fdc171bd6d7c6c2b6f667088c1889a826bbfe0
Contents?: true
Size: 966 Bytes
Versions: 20
Compression:
Stored size: 966 Bytes
Contents
# encoding: utf-8 $LOAD_PATH.unshift File.expand_path("../../../../lib", __FILE__) require "amqp" EventMachine.run do connection = AMQP.connect channel = AMQP::Channel.new(connection) replies_queue = channel.queue("", :exclusive => true, :auto_delete => true) replies_queue.subscribe do |metadata, payload| puts "[response] Response for #{metadata.correlation_id}: #{payload.inspect}" end # request time from a peer every 3 seconds EventMachine.add_periodic_timer(3.0) do puts "[request] Sending a request..." channel.default_exchange.publish("get.time", :routing_key => "amqpgem.examples.services.time", :message_id => Kernel.rand(10101010).to_s, :reply_to => replies_queue.name, :immediate => true) end Signal.trap("INT") { connection.close { EventMachine.stop } } end
Version data entries
20 entries across 20 versions & 1 rubygems