Sha256: 6a157c215c390cee75e0ace3b28a73db5a65c947e1947aaae8e80f3e6b781d0f

Contents?: true

Size: 903 Bytes

Versions: 3

Compression:

Stored size: 903 Bytes

Contents

#
# HornetQ Requestor:
#      Submit a request and wait for a reply
#

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

require 'rubygems'
require 'hornetq'

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

HornetQ::Client::Factory.start(:connector=> {:uri => 'hornetq://localhost'}) do |session|
  requestor = session.create_requestor('jms.queue.ExampleQueue')

  # Create non-durable message
  message = session.create_message(HornetQ::Client::Message::TEXT_TYPE,false)
  message.body = "Request Current Time"
  
  # Send message to the queue
  puts "Send request message and wait for Reply"
  if reply = requestor.request(message, timeout)
    puts "Received Response: #{reply.inspect}"
    puts "  Message: #{reply.body.inspect}"
  else
    puts "Time out, No reply received after #{timeout/1000} seconds"
  end
  
  requestor.close
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
jruby-hornetq-0.2.5.alpha examples/client/client.rb
jruby-hornetq-0.2.3.alpha examples/client/client.rb
jruby-hornetq-0.2.1.alpha examples/client/client.rb