How can I get all messages without using for a loop?
Use a while . Sorry, I could not resist a slightly mock answer to this question. WMQ does not have an API call similar to the SQL select statement. Messages and databases share some features, but require fundamentally different requirements.
It takes a long time to view 10,000 messages.
Take a look at Performance SupportPacs. They are published on the SupportPacs homepage and have names starting with MP. Find the one that suits your platform and MQ version, and it will list various scripts for posting and receiving messages, as well as recommendations for tuning performance.
I would also ask why a regular application should view 10,000 messages. QMgr will select the messages for you based on the MsgID, correlation ID or property, and this is much faster than viewing all the messages so that the application can find the messages you are interested in. Sometimes people need to look at all the messages in the queue in order to archive the queue or debug the problem, but this is an exception, not a rule. If the Production application regularly scans all messages in the queue, the queues may not be used correctly as a database.
T.Rob source share