All of the following do NOT read the message in the queue. I think they only read new messages that arrive
No. All messages on the Queue will be processed - though not necessarily by this QueueReceiver if more than one is defined from this Queue. Messages can be skipped if the QueueReceiver specifies a message selector.
If this is true I wonder why my Message msg = receiver.receiveNoWait(); is returning null.
1) I do have a MDB which is configured to listen on this queue. However I stopped the listener service on the server that the MDB is deployed on when I ran the above mentioned test code to read the first message off the queue.
2) When creating the queue I did not specify any message selector, which means I should be able to read ALL messages on the queue.
3) Using QueueBrowser qBrowser = qSession.createBrowser(q, null); I can browse the queue and I do see that there are 2 messages. i.e Using qBrowser.getEnumeration() I can see two Message objects in the queue.