def test_thread_multi_subscribe
lock = Mutex.new
msg_ctr = 0
dest = make_destination
1.upto(@max_threads) do |tnum|
Thread.new(@client) do |acli|
assert_nothing_raised {
if acli.protocol() == Stomp::SPL_10
acli.subscribe(dest) { |m|
msg = m
lock.synchronize do
msg_ctr += 1
end
sleep 0.05
}
else
acli.subscribe(dest, :id => acli.uuid()) { |m|
msg = m
lock.synchronize do
msg_ctr += 1
end
sleep 0.05
}
end
}
end
end
1.upto(@max_msgs) do |mnum|
msg = Time.now.to_s + " #{mnum}"
@client.publish(dest, message_text)
end
max_sleep = (RUBY_VERSION =~ /1\.8\.6/) ? 30 : 5
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(@client)
end