Sha256: dfe8a07772f0de626080e005201510e5913ee6dd2d41304eea834e866ba4a981

Contents?: true

Size: 1.05 KB

Versions: 6

Compression:

Stored size: 1.05 KB

Contents

#!/usr/bin/env jruby
#
# HornetQ Consumer:
#          Write messages to the queue
#

# Allow examples to be run in-place without requiring a gem install
$LOAD_PATH.unshift File.dirname(__FILE__) + '/../../lib'

require 'rubygems'
require 'yaml'
require 'hornetq'

timeout = (ARGV[0] || 3000).to_i

config = YAML.load_file(File.dirname(__FILE__) + '/hornetq.yml')
constants = config['constants']

# Create a HornetQ session
HornetQ::Client::Connection.session(config['client']) do |session|
  consumer = session.create_consumer(constants[:queue])
  session.start

  i = 0
  start_time = Time.now
  while message = consumer.receive(timeout)
    i += 1
    message.acknowledge
    expected_message = "Message ##{i}"
    if message.body != expected_message
      puts "Unexpected message: #{message.body} Expected: #{expected_message}"
      i = $1.to_i if message.body =~ /Message #(\d+)/
    end
    puts "#{i}\n" if i%1000 == 0
  end
  duration = Time.now - start_time - timeout/1000
  puts "Received #{i} messages in #{duration} seconds at #{i/duration} messages per second"
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
jruby-hornetq-0.5.0.alpha examples/transaction-failover/consumer.rb
jruby-hornetq-0.4.0 examples/transaction-failover/consumer.rb
jruby-hornetq-0.3.3 examples/transaction-failover/consumer.rb
jruby-hornetq-0.3.2 examples/transaction-failover/consumer.rb
jruby-hornetq-0.3.1 examples/transaction-failover/consumer.rb
jruby-hornetq-0.3.0.alpha examples/transaction-failover/consumer.rb