Sha256: 76c1a16eaf5fb94594635a80550e75b7c3cfe4063fd71efd7f30ca0b8ba7ef69

Contents?: true

Size: 845 Bytes

Versions: 5

Compression:

Stored size: 845 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 the non-durable TestQueue to receive messages sent to the TestAddress
  session.create_queue_ignore_exists('TestAddress', 'TestQueue', false)
  
  session.consumer('TestQueue') do |consumer|
    # Receive a single message, return immediately if no message available
    if message = consumer.receive_immediate
      puts "Received:[#{message.body}]"
      message.acknowledge
    else
      puts "No message found"
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

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