More ruby examples: broadcasting, unsubscribing
authorTony Garnock-Jones <tonyg@lshift.net>
Tue Sep 09 13:36:11 2008 +0100 (2008-09-09)
changeset 528972d204473a
parent 51 42a874db3d80
child 53 b0940cc0862a
More ruby examples: broadcasting, unsubscribing
examples/ruby/topic-broadcast-receiver.rb
examples/ruby/topic-broadcast-with-unsubscribe.rb
examples/ruby/topic-receiver.rb
examples/ruby/topic-roundrobin-receiver.rb
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/examples/ruby/topic-broadcast-receiver.rb	Tue Sep 09 13:36:11 2008 +0100
     1.3 @@ -0,0 +1,8 @@
     1.4 +require 'rubygems'
     1.5 +require 'stomp'
     1.6 +
     1.7 +conn = Stomp::Connection.open('guest', 'guest', 'localhost')
     1.8 +conn.subscribe('', :exchange => 'amq.topic', :routing_key => "x.#")
     1.9 +while mesg = conn.receive
    1.10 +  puts mesg.body
    1.11 +end
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/examples/ruby/topic-broadcast-with-unsubscribe.rb	Tue Sep 09 13:36:11 2008 +0100
     2.3 @@ -0,0 +1,15 @@
     2.4 +require 'rubygems'
     2.5 +require 'stomp' # this is a gem
     2.6 +require 'uuidtools' # this is a gem
     2.7 +
     2.8 +conn = Stomp::Connection.open('guest', 'guest', 'localhost')
     2.9 +subid = UUID.random_create.to_s
    2.10 +puts "Subscribing to #{subid}..."
    2.11 +conn.subscribe('', :id => subid, :exchange => 'amq.topic', :routing_key => "x.#")
    2.12 +puts 'Receiving...'
    2.13 +mesg = conn.receive
    2.14 +puts mesg.body
    2.15 +puts "Unsubscribing from #{subid}..."
    2.16 +conn.unsubscribe('', :id => subid)
    2.17 +puts 'Sleeping 5 seconds...'
    2.18 +sleep 5
     3.1 --- a/examples/ruby/topic-receiver.rb	Mon Aug 11 17:49:09 2008 +0100
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,8 +0,0 @@
     3.4 -require 'rubygems'
     3.5 -require 'stomp'
     3.6 -
     3.7 -conn = Stomp::Connection.open('guest', 'guest', 'localhost')
     3.8 -conn.subscribe('myqueue', :exchange => 'amq.topic', :routing_key => "x.#")
     3.9 -while mesg = conn.receive
    3.10 -  puts mesg.body
    3.11 -end
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/examples/ruby/topic-roundrobin-receiver.rb	Tue Sep 09 13:36:11 2008 +0100
     4.3 @@ -0,0 +1,8 @@
     4.4 +require 'rubygems'
     4.5 +require 'stomp'
     4.6 +
     4.7 +conn = Stomp::Connection.open('guest', 'guest', 'localhost')
     4.8 +conn.subscribe('myqueue', :exchange => 'amq.topic', :routing_key => "x.#")
     4.9 +while mesg = conn.receive
    4.10 +  puts mesg.body
    4.11 +end