Ok… some quick thoughts off the top of my head:
- Is the queue empty before your start your tests?
- Rather than creating new Date objects and using DateTimeInstance inside your tight loop, just use System.currentTimeMillis() in the payload
- Rather than 10 threads, practice with just one thread until your values are as expected. Simpler.
- Instead of publishing forever, run a test with 1000 messages. Or 10,000 at a higher rate.
- When doing proper latency tests, typically you’re building a histogram of results, putting latency deltas into a number of buckets, and then calculating the relative percentage of each bucket. What you DON’T want to do is any kind of I/O (write to console, screen, DB, etc.) when you receive the message in your consumer. You didn’t post your consumer code, but hopefully your onReceive() callback simply calculates the delta between “now” and the payload of the message, and stores that away for later calculations. Do not PRINT or DUMP the message to the console in the callback.
- sleep() is not very accurate… as your message rates increase, you may prefer to use a “busy wait” where you spin in a tight loop until the current system time has advanced by x milliseconds, or x microseconds.
- Please confirm you’ve removed the “latch” from the receiver code to ensure the receiver continues to run
Still, even without these improvements, you should never be seeing 5 minute delays. So I’m still wondering if there is some sort of timestamp / clock issue…?
Thanks!