Sha256: de8ad75ad54454d98eab970f10117dd92204ddbb17bdc21ad3035d3b0976063b

Contents?: true

Size: 940 Bytes

Versions: 3

Compression:

Stored size: 940 Bytes

Contents

#
# HornetQ Consumer:
#          Read a single message from the queue
#

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

require 'rubygems'
require 'hornetq'

# Using Connect.start since a session must be started in order to consume messages
HornetQ::Client::Connection.start_session('hornetq://localhost') do |session|
  
  # Create a non-durable TestQueue to receive messages sent to the TestAddress
  session.create_queue_ignore_exists('TestAddress', 'TestQueue', false)
  
  # Consume All messages from the queue and gather statistics
  stats = session.consume(:queue_name => 'TestQueue', :timeout=> 0, :statistics=>true) do |message|
    p message
    puts "=================================="
    message.acknowledge
  end
  puts "Received #{stats[:count]} messages in #{stats[:duration]} seconds at #{stats[:messages_per_second]} messages per second"
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
jruby-hornetq-0.3.3 examples/producer-consumer/consume_all.rb
jruby-hornetq-0.3.1 examples/producer-consumer/consume_all.rb
jruby-hornetq-0.3.0.alpha examples/producer-consumer/consume_all.rb