Sha256: 850aa29644f339b0583abd69c841651d450c7e235d33e8bcd3831a54e97a2f31
Contents?: true
Size: 1.47 KB
Versions: 1
Compression:
Stored size: 1.47 KB
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 'yaml' require 'hornetq' count = (ARGV[0] || 1).to_i timeout = (ARGV[1] || 30000).to_i config = YAML.load_file(File.dirname(__FILE__) + '/hornetq.yml')['development'] # Create a HornetQ session HornetQClient::Factory.create_session(config) do |session| #session.create_queue('Example', 'Example', true) requestor = session.create_requestor('jms.queue.ExampleQueue') session.start start_time = Time.now puts "Sending messages" count.times do |i| message = session.create_message(HornetQClient::Message::TEXT_TYPE,false) # Set the message body text message << "Request Current Time" # Set the user managed message id message.user_id = Java::org.hornetq.utils::UUIDGenerator.getInstance.generateUUID # Send message to the queue puts "Sending Request" if reply = requestor.request(message, timeout) puts "Received Response: #{reply.inspect}" puts " Message:[#{reply.body.inspect}]" #print "." else puts "Time out, No reply received after #{timeout/1000} seconds" end #p message puts "#{i}" if i%1000 == 0 puts "Durable" if message.durable end requestor.close duration = Time.now - start_time puts "\nMade #{count} calls in #{duration} seconds at #{count/duration} messages per second" end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
jruby-hornetq-0.2.0.alpha | examples/client.rb |