Skip to content

Instantly share code, notes, and snippets.

@xaviershay
Forked from tobias/service_service.rb
Created September 16, 2012 04:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xaviershay/3731012 to your computer and use it in GitHub Desktop.
Save xaviershay/3731012 to your computer and use it in GitHub Desktop.
A TorqueBox service that consumes from a queue.
class ServiceService
def initialize(options)
@queue = TorqueBox::Messaging::Queue.new( '/queues/service_request' )
@running = true
end
def start()
Thread.new do
while @running
request = @queue.receive( :timeout => 5000 )
if request && @running
puts request.inspect
end
end
end
end
def stop()
@running = false
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment