1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
# -*- encoding: utf-8 -*-
require 'rubygems'
require 'stomp'
#
# == Example topic consumer.
#
class ExampleTopicConsumer
# Initialize.
def initialize
end
# Run example.
def run
client = Stomp::Client.new("failover://(stomp://:@localhost:61613,stomp://:@remotehost:61613)?initialReconnectDelay=5000&randomize=false&useExponentialBackOff=false")
puts "Subscribing to /topic/ronaldo"
client.subscribe("/topic/ronaldo") do |msg|
puts msg.to_s
puts "----------------"
end
loop do
sleep(1)
puts "."
end
end
end
#
e = ExampleTopicConsumer.new
e.run
|