Sha256: 17bbf1323c0fcb13b397c6d3cc4ecd4365e64269432b014c3a463e2efbdbc0d9

Contents?: true

Size: 1.08 KB

Versions: 19

Compression:

Stored size: 1.08 KB

Contents

$:.unshift File.dirname(__FILE__) + '/../../lib'
require 'mq'

AMQP.start(:host => 'localhost') do

  def log *args
    p [ Time.now, *args ]
  end
  
  # AMQP.logging = true

  amq = MQ.new
  EM.add_periodic_timer(1){
    puts

    log :sending, 'ping'
    amq.queue('one').publish('ping')
  }

  amq = MQ.new
  amq.queue('one').subscribe{ |msg|
    log 'one', :received, msg, :sending, 'pong'
    amq.queue('two').publish('pong')
  }
  
  amq = MQ.new
  amq.queue('two').subscribe{ |msg|
    log 'two', :received, msg
  }

end

__END__

[Sun Jul 20 03:52:24 -0700 2008, :sending, "ping"]
[Sun Jul 20 03:52:24 -0700 2008, "one", :received, "ping", :sending, "pong"]
[Sun Jul 20 03:52:24 -0700 2008, "two", :received, "pong"]

[Sun Jul 20 03:52:25 -0700 2008, :sending, "ping"]
[Sun Jul 20 03:52:25 -0700 2008, "one", :received, "ping", :sending, "pong"]
[Sun Jul 20 03:52:25 -0700 2008, "two", :received, "pong"]

[Sun Jul 20 03:52:26 -0700 2008, :sending, "ping"]
[Sun Jul 20 03:52:26 -0700 2008, "one", :received, "ping", :sending, "pong"]
[Sun Jul 20 03:52:26 -0700 2008, "two", :received, "pong"]

Version data entries

19 entries across 19 versions & 6 rubygems

Version Path
adamh-amqp-0.6.3.1 examples/mq/pingpong.rb
brontes3d-amqp-0.6.4.0 examples/mq/pingpong.rb
brontes3d-amqp-0.6.4.1 examples/mq/pingpong.rb
brontes3d-amqp-0.6.4.2 examples/mq/pingpong.rb
brontes3d-amqp-0.6.4.3 examples/mq/pingpong.rb
brontes3d-amqp-0.6.4 examples/mq/pingpong.rb
fotonauts-amqp-0.6.1 examples/mq/pingpong.rb
fotonauts-amqp-0.6.4 examples/mq/pingpong.rb
tmm1-amqp-0.6.1 examples/mq/pingpong.rb
tmm1-amqp-0.6.3 examples/mq/pingpong.rb
tmm1-amqp-0.6.4 examples/mq/pingpong.rb
amqp-0.7.0.pre examples/mq/pingpong.rb
totty-amqp-0.6.7.1 examples/mq/pingpong.rb
totty-amqp-0.6.7.1.totty examples/mq/pingpong.rb
brontes3d-amqp-0.6.7.1 examples/mq/pingpong.rb
amqp-0.6.7 examples/mq/pingpong.rb
amqp-0.6.6 examples/mq/pingpong.rb
amqp-0.6.5 examples/mq/pingpong.rb
amqp-0.6.4 examples/mq/pingpong.rb