Parent

Methods

Class/Module Index [+]

Quicksearch

ExampleConsumer

Example message consumer.

Public Class Methods

new() click to toggle source

Initialize.

# File examples/consumer.rb, line 9
def initialize
end

Public Instance Methods

run() click to toggle source

Run example.

# File examples/consumer.rb, line 12
def run
client = Stomp::Client.new("failover://(stomp://:@localhost:61613,stomp://:@remotehost:61613)?initialReconnectDelay=5000&randomize=false&useExponentialBackOff=false")
puts "Subscribing ronaldo"
client.subscribe("/queue/ronaldo", {:ack => "client", "activemq.prefetchSize" => 1, "activemq.exclusive" => true }) do |msg|
  File.open("file", "a") do |f|
    f.write(msg.body)
    f.write("\n----------------\n")
  end

  client.acknowledge(msg)
end

loop do
  sleep(1)
  puts "."
end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.