2008-09-09 20:36:11 +08:00
|
|
|
require 'rubygems'
|
|
|
|
require 'stomp' # this is a gem
|
|
|
|
|
|
|
|
conn = Stomp::Connection.open('guest', 'guest', 'localhost')
|
2010-11-08 22:09:21 +08:00
|
|
|
puts "Subscribing to /topic/x"
|
|
|
|
conn.subscribe('/topic/x')
|
2008-09-09 20:36:11 +08:00
|
|
|
puts 'Receiving...'
|
|
|
|
mesg = conn.receive
|
|
|
|
puts mesg.body
|
2010-11-08 22:09:21 +08:00
|
|
|
puts "Unsubscribing from /topic/x"
|
|
|
|
conn.unsubscribe('/topic/x')
|
2008-09-09 20:36:11 +08:00
|
|
|
puts 'Sleeping 5 seconds...'
|
|
|
|
sleep 5
|