Sha256: 9a26fa674f8c63a020ec9eeeffd71718e1d0967259b4b1710369139610bca605

Contents?: true

Size: 907 Bytes

Versions: 33

Compression:

Stored size: 907 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)
  end



  Signal.trap("INT") { connection.close { EventMachine.stop } }
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
amqp-1.8.0 examples/patterns/request_reply/client.rb
amqp-1.7.0 examples/patterns/request_reply/client.rb
amqp-1.6.0 examples/patterns/request_reply/client.rb
amqp-1.5.3 examples/patterns/request_reply/client.rb
amqp-1.5.2 examples/patterns/request_reply/client.rb
amqp-1.5.1 examples/patterns/request_reply/client.rb
amqp-1.5.0 examples/patterns/request_reply/client.rb
amqp-1.4.2 examples/patterns/request_reply/client.rb
amqp-1.4.1 examples/patterns/request_reply/client.rb
amqp-1.4.0 examples/patterns/request_reply/client.rb
amqp-1.3.0 examples/patterns/request_reply/client.rb
amqp-1.2.1 examples/patterns/request_reply/client.rb
amqp-1.2.0 examples/patterns/request_reply/client.rb
amqp-1.1.8 examples/patterns/request_reply/client.rb
amqp-1.1.7 examples/patterns/request_reply/client.rb
amqp-1.1.6 examples/patterns/request_reply/client.rb
amqp-1.1.5 examples/patterns/request_reply/client.rb
amqp-1.1.4 examples/patterns/request_reply/client.rb
amqp-1.1.3 examples/patterns/request_reply/client.rb
amqp-1.0.4 examples/patterns/request_reply/client.rb