I have attached a test that fails intermittently for myself using the latest master of WildFly which contains the 2.4.0.Beta2 version of HornetQ.
You must have a queue called: BTR_TestOne
You may need to have some setting on the InVm connection factory, I have include my HQ config in case it is pertinent.
Run the attached Arquillian test, it should fail because the second message is not received.
If I change the "receive()" to a "receive(20000)" (and disable the thread that calls close on the connection), then after 20000, the receive does indeed return with the message. With a "receive()" I only occasionally receive the message. If I do not call stop/start on the connection I always receive the message.
I have worked around this in my own project by not calling start before I call "receive()" but it could affect others.
To summarise, there seems to be a problem calling:
// Second thread calls connection.start()
Hope that helps,