examples/advanced/multi_client.rb in jruby-hornetq-0.4.0 vs examples/advanced/multi_client.rb in jruby-hornetq-0.5.0.alpha

- old
+ new

@@ -19,11 +19,11 @@ # Sample thread that does some work and then does a request-response call def worker_thread(id, connection, timeout, request_count) begin connection.start_session do |session| start_time = Time.now - + # Use Requestor (Client) Pattern to do a "RPC like" call to a server # Under the covers the requestor creates a temporary dynamic reply to queue # for the server to send the reply message to session.requestor('ServerAddress') do |requestor| # Create non-durable message @@ -31,21 +31,21 @@ (1..request_count).each do |i| message = session.create_message(HornetQ::Client::Message::TEXT_TYPE,false) message.body = "Some request data" # Set the user managed message id message.user_id = Java::org.hornetq.utils::UUIDGenerator.getInstance.generateUUID - + if reply = requestor.request(message, timeout) puts "Thread[#{id}]:Received Response: #{reply.inspect}" if request_count < 10 puts "Thread[#{id}]: Message:[#{reply.body.inspect}]" if request_count < 10 print ".#{id}" if request_count >= 10 else puts "Thread[#{id}]:Time out, No reply received after #{timeout/1000} seconds" end puts "Thread:#{id}=>#{i}" if i%1000 == 0 end end - + duration = Time.now - start_time puts "\nThread[#{id}]:Made #{request_count} calls in #{duration} seconds at #{request_count/duration} synchronous requests per second" end rescue Exception => exc \ No newline at end of file