How to see information on each message in a queue

Options
hong
hong Guest Posts: 480 ✭✭✭✭✭
edited September 2023 in Tips and Tricks #1

Problem

You want to check the messages you are sending for error checking or validation but don’t know how to do that.

Prerequisite

Download Solace Java or .NET APIs
Download SDKPerf

Solution
You can do that in two ways:

  • Option 1: Use a queue browser with either the Solace Java or .NET API or SDKPerf
  • Option 2: Use Solace Command Line Interface (CLI)

For both options, make sure that at the end you log in to PubSub+ Manager to see that the messages are still spooled on the queue.

Option 1: A -- Use a queue browse with the Solace Java or .NET API

To see information on each message in a queue using the Solace Java or .NET API, follow these steps.

Option 1: B – Use a queue browser with SDKPerf

With SDKPperf, you can add a -md flag to dump the message to the screen to see the message as your queue browser.

To see information on each message in a queue using SDKPerf for testing, follow these steps:

  1. Type the command _sdkperf_java -cip tcp://<ip address>:5555 -cu <client_username>@<vpn> -pql=<queue> -mt=persistent -mn=<number of messages to send>_ to write messages to a queue with no consumers.

    Here is an example: sdkperf_java_d34 -cip tcp://192.168.133.47:55555 -cu wade_cu@wade_vpn -pql=wade_q -mt=persistent -mn=10 -msa=100

  2. Type the command_sdkperf_java -cip tcp://<ip address>:5555 -cu <client_username>@<vpn> -sql=<queue> -md -qb_ to browse the messages with a queue browser.

    Here is an example: sdkperf_java_d34 -cip tcp://192.168.133.47:55555 -cu wade_cu@wade_vpn -sql=wade_q –qb -md

Option 2

To see information on each message in a queue without consuming them using Solace CLI, follow these steps:

  1. Log in to the CLI through either the management console or Secure Shell (SSH) connections.
  2. Type the command _show queue <queueName> message-vpn <vpnName> message detail_.

The output shows you the information on each message in the queue, such as the date spooled, the message size, and the sequence number.

Result

You should be able to see the information on each message in your queue now.

Learn more
*Documentation: Browsing Guaranteed Messages

Comments

  • pruffieux
    pruffieux Member Posts: 13 ✭✭
    Options

    Learn more
    *Documentation: Browsing Guaranteed Messages

    Seems the link is dead. I would be interested to get one message instance in the message browser (Java) without looping over the whole set of messages.

  • marc
    marc Member, Administrator, Moderator, Employee Posts: 921 admin
    Options

    Thanks @pruffieux, link fixed!

  • pruffieux
    pruffieux Member Posts: 13 ✭✭
    Options

    With the given link, it seems not possible to take the body of a single specific message. I would be interested to know how to get a single message body when knowing the messageId and the replicationGroupMessageId

  • Aaron
    Aaron Member, Administrator, Moderator, Employee Posts: 534 admin
    edited April 10 #5
    Options

    Hi @pruffieux, welcome back to your old thread..!

    I've written a tool to do exactly this. Download a copy here: https://github.com/SolaceLabs/pretty-dump/releases/latest/download/PrettyDump.zip

    README docs are here.

    Then, run it with -h to see command-line help. But essentially you'll do:

    $ bin/PrettyDump url vpn user pw b:queueName
    
    Browse all messages -> press [ENTER],
     or enter specific Message ID,
     or range of IDs (e.g. "25909-26183" or "9517-"):
    

    Then you just type in the specific Message ID. Doesn't work with replicationGroupMessageId. Yet. That's maybe a good idea.

    NOTE: this is a Java tool, so you'll need a JRE. The next version will also be available as a Docker image.

  • pruffieux
    pruffieux Member Posts: 13 ✭✭
    Options

    Thanks for sharing your solution. As I am interested by doing this in Java, I notice in your code you're looping over the whole queue and exit when you find the given messageID (for a single search).

    I knew I can do that but I was thinking there is perhaps a more efficient way to do it. I am note sure about the performance if a queue contains thousands (or millions) of messages.

  • Aaron
    Aaron Member, Administrator, Moderator, Employee Posts: 534 admin
    edited April 12 #7
    Options

    Yeah, if there's millions or billions of messages, this approach could/would be quite inefficient. Another option is to use the more recent broker feature of copying a message from one queue to another. If you happen to know the message's Replication Group Message Id, you can use that to copy the message. This is different than the Message ID above (which is the message spool ID in the broker).

    For example, let's say I have a billion messages on my queue, but I just want to browse the most recent one. I can use the CLI command show queue q1 message-vpn default messages newest detail

    Name: q1
    Message VPN: default
    Message Id: 4187008
    Priority:                     n/a
    Date spooled:                 Apr 12 2024 09:25:33 UTC
    Replication Group Message Id: rmid1:2cf0b-4a19b6301d4-00000000-003fe380   <--- 
    Sequence Number:              n/a
    Expiry Time:                  never
    Delivery Eligible Time:       now
    Dead Message Queue Eligible:  yes
    Content:                      0.0000 MB
    Attachment:                   0.0003 MB
    Replicated:                   no
    Replicated Mate Message Id:   n/a
    Sent:                         no
    Redeliveries:                 0
    PartitionKey:
    PartitionKeyHash:             0
    

    I could make a temporary queue tempQ. And then run the CLI commands:

    enable
    admin
    message-spool message-vpn default
    copy-message source queue q1 destination queue tempQ message rmid1:2cf0b-4a19b6301d4-00000000-003fe380
    show tempQ
    
    Queue Name                     Messages      Spool             Bind Status
    Message VPN                     Spooled  Usage(MB)   HWM (MB) Count I E A S D P
    
    tempQ
    default                               1       0.00       0.00     0 U U E N D N
    

    Then browse/consume that.

    If you know how to do SEMPv1, the equivalent copy command would be:

    <rpc>
        <admin>
            <message-spool>
                <vpn-name>default</vpn-name>
                <copy-message>
                    <source/>
                    <queue-name>q1</queue-name>
                    <destination/>
                    <queue-name>tempQ</queue-name>
                    <message/>
                    <replication-group-msg-id>rmid1:2cf0b-4a19b6301d4-00000000-003fe380</replication-group-msg-id>
                </copy-message>
            </message-spool>
        </admin>
    </rpc>