examples/client/advanced/batch_client.rb in jruby-hornetq-0.2.3.alpha vs examples/client/advanced/batch_client.rb in jruby-hornetq-0.2.5.alpha
- old
+ new
@@ -23,11 +23,11 @@
batching_size = (ARGV[1] || 10).to_i
request_address = 'jms.queue.ExampleQueue'
config = YAML.load_file(File.dirname(__FILE__) + '/hornetq.yml')['development']
-class BatchClient
+class BatchClientPattern
def initialize(session, request_address)
@producer = session.create_producer(request_address)
reply_queue = "#{request_address}.#{Java::java.util::UUID.randomUUID.toString}"
begin
session.create_temporary_queue(reply_queue, reply_queue)
@@ -60,11 +60,11 @@
# Send x messages
def send(total_count)
#print "Sending #{total_count} messages"
start_time = Time.now
total_count.times do |i|
- message = @session.create_message(HornetQ::Client::Message::TEXT_TYPE,false)
+ message = @session.create_message(HornetQ::Client::Message::TEXT_TYPE,true)
message.reply_to_queue_name = @consumer.queue_name
message.body = "Request Current Time. #{i}"
@producer.send(message)
print "."
#puts "Sent:#{message}"
@@ -97,10 +97,10 @@
# Create a HornetQ session
HornetQ::Client::Factory.session(config) do |session|
batching_size = total_count if batching_size > total_count
- client = BatchClient.new(session, request_address)
+ client = BatchClientPattern.new(session, request_address)
# Start receive thread
receive_thread = Thread.new {client.receive}
times = (total_count/batching_size).to_i