Use a QueueBrowser.You have to iterate through the whole queue (effectively fetching all the messages), but the messages stay in the queue for others to consume.Note that the browser may be a snapshot. It takes time to iterate and it can change while you iterate. Even if your provider offers a cursor like browser, messages can be consumed and produced behind you.
Most vendors have some sort of administrative API to get this information. It would not be considered portable.