Skip to content

Instantly share code, notes, and snippets.

@roidrage
Created August 30, 2009 11:27
Show Gist options
  • Save roidrage/177929 to your computer and use it in GitHub Desktop.
Save roidrage/177929 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'eventmachine'
require 'mq'
require 'amqp'
AMQP.logging = true
AMQP.start(:user => 'nanite', :pass => 'testng', :vhost => '/nanite', :host => 'localhost', :port => ::AMQP::PORT, :insist => false, :retry => 5) {
clock = MQ.new.fanout("clock", :durable => true)
EM.add_periodic_timer(1) {
puts 'tick!'
clock.publish(Marshal.dump(Time.now))
}
amq = MQ.new
amq.queue('every second').bind(amq.fanout('clock')).subscribe{ |time|
puts 'every second', :received, Marshal.load(time)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment