Browsing Queues

1 Minute Read

This sample shows how to use a Browser to look at the Queue's contents.

Feature Overview

Client applications using the Java and .NET APIs can use the Browser interface to look at Guaranteed messages spooled for a Queue in the order of oldest to newest without consuming them. The Browser can also be used to remove messages from the Queue.

A Browser could be used by an application to pre-screen messages by detecting message content that could cause fatal conditions and removing the messages before they are processed.


The Client Profile must be configured to allow receiving guaranteed messages

NOTE: This is the default configuration in PubSub+ Cloud messaging services.


The following code creates a Browser and gets messages from a Queue without removing them. The Browser is also able to remove messages from a Queue and this is shown in the code below by removing only the 3rd message.

BrowserProperties br_prop = new BrowserProperties();
Browser myBrowser = session.createBrowser(br_prop);
BytesXMLMessage rx_msg = null;
int rx_msg_count = 0;
do {
    rx_msg = myBrowser.getNext();
    if (rx_msg != null) {
        System.out.println("Browser got message... dumping:");
        if (rx_msg_count == 3) {
            System.out.print("Removing message from queue...");
} while (rx_msg != null);                    

Learn More

Spraint is the proper name for otter dung