You can either do the enumeration thing described in that other answer which won't get you the correct answer in many cases or you can use the statistics broker plugin and query that data from the broker.
With the statistics plugin you can send a message to a control queue and listen for a response on the replyTo destination you provide and get the full statistics of the destination, the caveat being that you need to parse out the data but that shouldn't be that hard.
The enumeration method won't lock the queue but it won't work the way you want because there is a limit to the depth that the broker will go into a deep queue before stopping when it is feeding a QueueBrowser so you can't be sure you got a correct count. Also using the statistic plugin results in less broker overhead and network traffic since the broker only has to send you one response with the data in it verses sending you all the messages just for the sake of counting.