examples/ruby/topic-broadcast-with-unsubscribe.rb
changeset 52 8972d204473a
child 237 1001ca6867cf
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/examples/ruby/topic-broadcast-with-unsubscribe.rb	Tue Sep 09 13:36:11 2008 +0100
     1.3 @@ -0,0 +1,15 @@
     1.4 +require 'rubygems'
     1.5 +require 'stomp' # this is a gem
     1.6 +require 'uuidtools' # this is a gem
     1.7 +
     1.8 +conn = Stomp::Connection.open('guest', 'guest', 'localhost')
     1.9 +subid = UUID.random_create.to_s
    1.10 +puts "Subscribing to #{subid}..."
    1.11 +conn.subscribe('', :id => subid, :exchange => 'amq.topic', :routing_key => "x.#")
    1.12 +puts 'Receiving...'
    1.13 +mesg = conn.receive
    1.14 +puts mesg.body
    1.15 +puts "Unsubscribing from #{subid}..."
    1.16 +conn.unsubscribe('', :id => subid)
    1.17 +puts 'Sleeping 5 seconds...'
    1.18 +sleep 5