def test_multi_thread_receive
lock = Mutex.new
msg_ctr = 0
dest = make_destination
1.upto(@max_threads) do |tnum|
Thread.new(@conn) do |amq|
while true
received = amq.receive
lock.synchronize do
msg_ctr += 1
end
sleep 0.05
end
end
end
conn_subscribe( dest )
1.upto(@max_msgs) do |mnum|
msg = Time.now.to_s + " #{mnum}"
@conn.publish(dest, msg)
end
max_sleep = (RUBY_VERSION =~ /1\.8/) ? 30 : 5
max_sleep = 30 if RUBY_ENGINE =~ /mingw/
sleep_incr = 0.10
total_slept = 0
while true
break if @max_msgs == msg_ctr
total_slept += sleep_incr
break if total_slept > max_sleep
sleep sleep_incr
end
assert_equal @max_msgs, msg_ctr
checkEmsg(@conn)
end