Is there a way to delete a single message from an MQ queue?

IBM Support recently released a Support Doc which posed the question:-

Question

Is there a way to delete a single message from an MQ queue (arbitrary position in the queue)?

The document described a couple of options. In this post we cover how to do this using MQGem tools as several of them offer this capability. Open up the twisty for each tool to read how to do this.

Using MO71

In MO71 you can browse a list of messages on a queue, then from that list, select an individual message (or multiple messages if you need to). Then press the Delete button, or select Delete from the right-mouse button context menu and the selected message(s) will be deleted.

MO71 uses the MQ facility, get by message token, so only the exact message(s) that you select from the list will be deleted. While the position of the message on the queue is shown, this is not used for deletion and neither is Message Id, since there is no guarantee that this will be unique either. Each message on a queue is guaranteed to have a unique Message Token.

Alternatively, you can double click on a message from the list, to view the whole message individually. Then from that display, having checked all the details, and made sure it is the message you want to delete, you can press the Delete button, or select Delete from the context menu.

Take care when deleting messages from a production queue manager. Consider that it might be safer to Move the message(s) to a separate holding queue, just in case the message proves to be important after all. MO71 makes it simple to Move messages too. Just fill in the holding queue name, and then press the Move, rather than Delete, button.

Using the Q program

To delete a single message from an MQ queue using the Q program, you should first discover the message ID of the message you wish to delete, to ensure you are addressing the correct message that you intend to delete. Do this by displaying the messages on the queue like this:-

q -m MQG1 -i Q1 -dd

This will browse (-i) the messages on the queue and display the MQMD after the MQGET (-dd) allowing you to see the Message ID of each message on the queue. You will see output like this for each message:-

==============================================================
----- MQMD after MQGET -----
[  324 bytes] Message Descriptor (MQMD)
Report       :00000000
Message Type :8 (Datagram)
Format       :'MQSTR   ' (String)
Priority     :0 (Lowest)
Persistence  :0 (Not Persistent)
Message Id   :414D51204D514731202020202020202099FA4A6020B74B02
              A M Q   M Q G 1                 . ú J `   · K .
ReplyToQ     :'                                                '
ReplyToQMgr  :'MQG1                                            '

Now you can copy that message ID and use it on another invocation of the Q program to delete that specific message from the queue.

q -m MQG1 -IQ1 -gxm:414D51204D514731202020202020202099FA4A6020B74B02

Bear in mind that message IDs are likely to be unique, but this is not guaranteed. It would be safer to move the messages to a separate queue, before deletion. This is simple to achieve using a command like the following:

q -m MQG1 -IQ1 -o HOLDING.Q 
-gxm:414D51204D514731202020202020202099FA4A6020B74B02
Using QLOAD

If you have already browsed the queue contents and output them to a file, you can find the message Id of the specific message you are attempting to address by looking for the Message Descriptor attribute “MSI”. Here is a snippet from a QLOAD file to show an example.

A FMT MQSTR
A PRI 0
A PER 0
A MSI 414D51204D514731202020202020202099FA4A6020B74B02
A COI 000000000000000000000000000000000000000000000000

Now you can copy that message ID and use it on another invocation of the QLOAD program to delete that specific message from the queue. We would recommend using QLOAD to actually move that message to an output file, in case you change your mind about deleting it!

qload -m MQG1 -IQ1 -f c:\temp\deletedmsg.qld 
-gxm414D51204D514731202020202020202099FA4A6020B74B02

Alternatively, you can use the very flexible search and filtering capabilities of QLOAD to narrow down your search of messages on the queue until you find the one you wish to delete, and then offload it to a file, or delete it entirely.

For example, this invocation removes all messages on a queue that are older than one week, and moves them instead to the named file:-

qload -m MQG1 -I Q1 -T7:0:0 -f c:\temp\oldmsgs.qld

Another example, here we remove messages larger than 1MB from a queue:-

qload -m MQG1 -I Q1 -z 1M -f c:\temp\bigmsgs.qld

A third example, here we remove message containing the string “Acme Limited”:-

qload -m MQG1 -I Q1 -s "Acme Limited" -f c:\temp\acmemsgs.qld
Using MQEdit

In MQEdit you can browse a list of messages on a queue, then from that list, select an individual message (or multiple messages if you need to). Then press the Delete button, or select Delete from the right-mouse button context menu.

MQEdit uses the MQ facility, get by message token, so only the exact message that you select from the list will be deleted. While the position of the message on the queue is shown, this is not used for deletion and neither is Message Id, since there is no guarantee that this will be unique either. Each message on a queue is guaranteed to have a unique Message Token.

Alternatively, you can double click on a message from the list, to view the whole message individually in the pane below, and then from that pane, having checked all the details, and made sure it is the message you want to delete, you can select “Delete Message” from the context menu.

Particularly for production queue managers, we would always suggest that it is safer to move message(s) to a holding queue rather than deleting them immediately. In MQEdit it is very simple to move a message between queues, all you need do is drag and drop the required message(s) from one queue to another. You can even copy and move messages between queue managers this way.


If you don’t have any of these tools, but would like to try any or all of them out, please contact support@mqgem.com and a 1-month trial licence will be sent to you with no obligation to buy. You can download the tools from our website.

MQEdit version 9.2.1

This V9.2.1 release of MQEdit, our Live Parsing Editor for IBM MQ messages, has focused on improving its support for COBOL data types and features. The main features of the release are as follows:-

  • Utility to make MQEdit User Format files from COBOL copybooks

    Are your IBM MQ messages built from a COBOL copybook? Would you like an easy way to create an MQEdit User Format file directly from that COBOL copybook? Released at the same time as this new MQEdit release is a free utility called MakeFmt which automates this process. Read this separate blog post covering this new utility. As an example, the following COBOL copybook would translate as shown into an MQEdit User Format file.

  • Support for Packed Decimal Fields

    In order to be able to create MQEdit User Formats for IBM MQ messages that are built from COBOL copybooks, MQEdit now natively supports the packed decimal datatype. See the above diagram for an example of COBOL packed decimal fields translating into an MQEdit User Format packed data type.

  • Support for S/390 format floating point numbers

    If you’re using COBOL, likely as not your messages are originating on an IBM z/OS machine. While in newer versions of z/OS hardware, there is support for IEEE floating point numbers, the S/390 style of floating point numbers are still very much in use. This version of MQEdit is able to display and edit floating point numbers (single and double precision) in both IEEE 754 and HPF formats. MQEdit refers to the Message Descriptor Encoding field (or Encoding field in any chained headers) to determine how any floating point numbers it comes across should be treated:-

    • MQENC_FLOAT_IEEE_NORMAL
    • MQENC_FLOAT_IEEE_REVERSED
    • MQENC_FLOAT_S390

    What if your message does not set the correct value in the Encoding field – see the last item in this list!

  • Allow arrays of strings

    MQEdit previously had the concept of arrays. If you had a string field, it was a character array. For example a 40-character string might look like this in a MQEdit User Format:-

     char     ADDRESS_LINE[40];

    Now, you can also have arrays of strings, for example if you need an array of 4 40-character strings, it would look like this:-

     char     ADDRESS_LINE[40][4];

    For those of you that speak COBOL, this is the equivalent of:-

        10  ADDRESS-LINE    PIC X(40) OCCURS 4 TIMES.
  • Formatting dates in your messages

    If your IBM MQ messages contain fields that contain dates, your MQEdit User Format can describe the format of those fields so that the date can be displayed in a way that everyone viewing the message can understand. For example, imagine you had a character field that contained the following characters:-

    020304

    and you told everyone that it was a date. Which date might it be? 2nd March 2004? 4th March 2002? February 3rd 2004? With an international audience, it may well be very useful to understand the format of such fields when viewing the contents of a message.

    The following MQEdit User Format:-

    enum_int levels
    {
      1, "Gold";
      2, "Silver";
      3, "Bronze";
    }
    struct MEMBER
    {
      char         NAME[40];
      char(YYMMDD) JOIN_DATE[6];
      int          LEVEL(levels);
    }

    would be displayed by MQEdit in the following way.

    [   50 bytes] MEMBER
    NAME        :'Morag Hughson                           '
    JOIN_DATE   :020304           4th March 2002
    LEVEL       :1 (Gold)
    End of structure 'MEMBER' (50 bytes)

    I’m sure you can imagine how handy this might be, and even more so with Julian dates, as I don’t know anyone who can calculate those in their head.

  • Character based enumerations

    Earlier versions of MQEdit had support for enumerations of integral number sets. The above example showed a Gold/Silver/Bronze membership level and how it is formatted.

    This version of MQEdit extends that to allow enumerations for sets of character strings. Here’s a small example:-

    enum relationships
    {
      "S", "SPOUSE";
      "P", "PARTNER";
      "F", "FRIEND";
    }
    struct PERSON
    {
      char   NAME[40];
      char   RELATIONSHIP(relationships);
    }

    which would be displayed by MQEdit in the following way.

    [   41 bytes] PERSON
    NAME        :'Big Ears                                '
    RELATIONSHIP:F (FRIEND)
    End of structure 'PERSON' (41 bytes)

    This type of enum can be used with char, packed, float and double type fields.

  • Show enumeration and field description values in message summary

    In an MQEdit User Format, you can identify particular fields that should be shown in a message summary. In the picture below the Product field and the Website URL field are marked as summary fields. If you look in the message list at the top of the screen you can see that each message shows the contents of these two fields as the summary of the message. However, the Product field is an integer field, and rather than showing the integer value, it shows the enumeration description of that integer value which is much more useful.

    Showing how fields marked as ‘summary’ in an MQEdit User Format are displayed as the Message Summary in the message list

  • Override Message Codepage, Encoding and Format

    In a perfect world, all MQ Message Descriptors would contain the correct code page, encoding and message format to describe the message that followed. Unfortunately, we live in the real world, and it is not always so. An application that knows all the character fields in its message are in EBCDIC doesn’t need to look at the MQMD.CodedCharSetId so it doesn’t matter if it says something else. Tools like MQEdit, however, don’t know what the application can assume.

    So, if you have some messages that are not correctly described when it comes to these fields, you can tell MQEdit what it needs to know to display them correctly. Here’s an example of an override section in an MQEdit User Format file.

    queue PRODUCT.DATA
    {
      format *
      {
        override
        {
          CodedCharSetId = 500;
          Encoding       = 0x311;
        }
        struct MQGEM;
      }
    }

    This tells MQEdit that messages on the queue called PRODUCT.DATA are actually in codepage 500 (EBCDIC) and native z/OS encoding regardless of what it might say in the Message Descriptor. When displaying the contents of the message, MQEdit will use those values, rather than the ones in the Message Descriptor and will display the Message Descriptor as follows to show you that an override is in effect.

    Feedback     :0 (None)
    MQEncoding   :0x'222' (Reversed)        Override(0x'311')
    CCSID        :437 (IBM PC)              Override(500)
    Format       :'MQGEM   '
    Priority     :0 (Lowest)

The new version can be downloaded from the MQEdit Download Page. Any current licensed users of MQEdit can run the new version on their existing licence. If you don’t have a licence and would like to try out MQEdit then send an email to support@mqgem.com and a 1-month trial licence will be sent to you.

MQEdit version 9.2.0 is released

MQGem Software is pleased to announce that a new version of MQEdit, our Live Parsing Editor for IBM MQ messages, is now available.

The main features of the release are as follows:-

  • Change the value of a field for many locations at once
    This feature was initially added in MO71, and by customer request, we have also added the same to MQEdit.

    If you have lots of queue managers, and you need to change something in the location definition for a number of them, this new dialog can make your life much easier. You can now change values in multiple location definitions at once. For example, if you wanted to change the CCDT URL you use for connectivity details. See Using the CCDT URL for more details on this. To change the CCDT URL by editing individual location definitions one by one would take some time, so now you can easily do it with the “Change Multiple Locations” feature of MQEdit.

    Open the dialog from the MQEdit File menu; select the queue managers to be changed in the left hand list; choose the field to be updated in the right hand list; type in the new value in the entry box and press Set New Value.

    MQEdit – Change Multiple Location dialog, showing CCDT URL
    Please note, the URL shown is for demonstration purposes only. There is no CCDT at the shown URL!

    There are quite a number of fields in the location dialog that you might find it helpful to update many at once. Take a look to see if any of those provided would be helpful to you.

  • Set locations to be members of the same security group
    This feature was initially added in MO71, and by customer request, we have also added the same to MQEdit.

    Do you have queue managers using user IDs and passwords? Are a number of them in the same security domain, for example, you have AD set up; or multiple z/OS queue managers in the same RACF; or you are using LDAP for your authentication? To save you having to make lots of changes each time you set up a new password on one of these domains, MQEdit now has the concept of a security group. You can indicate queue managers are members of the same security group in their location and then when you change the password of one member of the security group, all other members get that update too. This saves you having to provide the new password on every queue manager on password change day.

    This security group is just a name for MQEdit, it doesn’t have to match the domain, or group name or anything defined in a security repository. It is simply a grouping to tell MQEdit that these queue managers all use the same user id and password at connection time.

    MQEdit Location Dialog – Security Group settings and Upper Case of Userid and Password

    The description is optional, but if provided will be used in the password prompt box that is displayed when you connect to a queue manager, or press the Set Password button, as shown in the screenshot above.

    In order to initially set up the security group each queue manager is in, you can also use the “Change Multiple Locations” dialog described above.

  • New options to automatically fold Userid and Password fields to uppercase
    Another customer requested feature. You can select either or both of your Userid and Password fields for a location be folded to uppercase. See the screenshot above which also illustrates this feature. Note that when selected, the dialog where you type in your password will remind you that you have these settings on.

    This can be especially useful for z/OS TSO logins where it can be easy to forget that you have an upper case password because the TSO login panel always folds it to upper case for you.

  • Remember main window search strings
  • The two search fields, for searching Locations and Queues, are now combo-boxes which will be populated with any search strings you use for easy future retrieval.

    Search fields remember previously used search strings


The new version can be downloaded from the MQEdit Download Page. Any current licensed users of MQEdit can run the new version on their existing licence. If you don’t have a licence and would like to try out MQEdit then send an email to support@mqgem.com and a 1-month trial licence will be sent to you.

Text Files in Preview Pane

If you’re anything like me, you have a number of text files on your Windows machine that do not use the .txt file extension.

For all of these I have associated Notepad as the application to be used by default when I double click on these file types from the Windows File Explorer. I’m probably a 70:30 command line vs File Explorer user, but it is from time to time handy to be able to double click too.

What I’d never managed to figure out though (until today) was how to get the preview pane in Windows File Explorer to display these text formats with different file extensions. Now that I have found out how to do it, I thought I would share it with all of you too.

Windows File Association Dialog

Windows File Association Dialog

Firstly, it’s important to have the file association in place first, specifically the “Always use this app to open … files” checkbox. This seems to be what adds the file extension into the list you are about to manipulate. So take a moment to make sure all the extensions you want to preview have a default application set.

Now open the registry editor and navigate to Computer > HKEY_CLASSES_ROOT. In here you will see a list of all the file extensions your machine knows about. Locate your file extension that you want to preview (remember you can type into the entry field just below the menu bar). Select the file extension, in this example I am fixing up the .mqx extension; and on the right hand pane right-click and select New > String Value. Give the new key the name “PerceivedType” and then modify it to give it the data value of “text”.

Adding a new String Value in Windows Registry

Adding a new String Value in Windows Registry

Giving new registry key a value of text

Giving new registry key a value of text

Now go back to your File Explorer and you should be able to see your .mqx file in the preview pane.

View .mqx file in Preview Pane

View .mqx file in Windows File Explorer Preview Pane


Many thanks to Scott Williams who wrote about this in a blog post in 2013 which I finally stumbled across in 2020 and it made my day!

MQEdit version 9.1.0 is released

MQGem Software is pleased to announce that a new version of MQEdit, our Live Parsing Editor for IBM MQ messages, is now available.

The main reason for the new MQEdit version number, Version 9.1.0, is to remain inline with the current MQ version. However, the following functional changes have also been made:

  • Character Substitution Mode
    As requested by a customer, to make it easier to read certain types of messages, MQEdit now supports a Character Substitution Display Mode. This will display text such as > as the character ‘>’.

    MQEdit Character Substitution Mode

    MQEdit Character Substitution Mode. The top message can be displayed in the manner shown at the bottom with this formatting mode turned on

    The substitutions performed are the following:-

    Sequence Character displayed
    > >
    &lt; <
    &nbsp; (space)
    &amp; &
    &quot; "
    &apos; '
  • QLOAD ‘other’ file processing
    As a result of another customer request, it is now possible to use the QLOAD feature to load a ‘normal’ text file rather than a standard QLOAD file. This text file may contain multiple messages with some sort of delimiter, common with JSON or XML for example. The file can be parsed into these individual messages before being loaded onto the queue.
    MQEdit QLOAD Other File with delimiters

    Loading a file with message delimiters onto a queue

  • Select All
    To make it easier to copy/paste the entire message a new Select All (Ctrl-A) action has been added.

The new version can be downloaded from the MQEdit Download Page. Any current licensed users of MQEdit can run the new version on their existing licence. If you don’t have a licence and would like to try out MQEdit then send an email to support@mqgem.com and a 1-month trial licence will be sent to you.

MQEdit version 9.0.3 is released

MQGem Software is pleased to announce that a new version of MQEdit, our Live Parsing Editor for IBM MQ messages, is now available.

This version of MQEdit makes it easier to manage a group of users using the editor from a central position. The following items have been added:

  • The concept of a master configuration file
    Users can reference a master configuration file and any new or change locations can be automatically imported into their own configuration.
  • Import from another MQEdit (or MO71) Configuration file
    You can now import locations direct from another configuration file.
  • Splash screens
    An MQ Administration department can now cause users of MQEdit to see centrally controlled information whenever the user starts MQEdit or attempts to connect to a Queue Manager. This could, for example, display maintenance schedule information, Queue Manager ownership or support contact numbers.
  • Licence Command
    You can now configure a command to be automatically run if the current licence is either invalid or nearing its renewal date.
  • MQEdit Program update notification
    You can ask MQEdit to periodically check whether there is a later version of the program available.

The new version can be downloaded from the MQEdit Download Page. Any current licensed users of MQEdit can run the new version on their existing licence. If you don’t have a licence and would like to try out MQEdit then send an email to support@mqgem.com and a 1-month trial licence will be sent to you.

Use MQGem tools with IBM MQ on IBM Cloud

You may have seen the recent announcement from IBM about the experimental IBM MQ service running on IBM Cloud.
IBM Cloud

You can learn more with these resources:-

When you read the description of this new service in the Bluemix catalog, you’ll see it says the following:-

Manage MQ your way

Manage your cloud-based queue managers with the tools you know and love – including MQ Explorer, the MQ Console, or via MQ Script Commands (MQSC).

This blog post is here to assure you that the tools you know and love from MQGem Software; MO71, MQSCX, MQEdit and QLOAD can all also be used with IBM MQ running on IBM Cloud.

Once you have created your MQ on IBM Cloud Service and Queue Manager, as shown in the above video, and your queue manager is up and running, you’ll have a view something like this.

IBM Cloud QM List

A list showing my Running queue manager

Click on the three vertical dots on the right of your queue manager to “Download Connection info”, or alternatively view the details of your queue manager and then there is a button there too which allows you to download the “Connection Information”. Either way, you’ll be presented with a pop-up which allows you to download a plain text file which contains the queue manager name, hostname, port number and a couple of channel names, one called an Application Channel and one called an Administration Channel.

IBM Cloud Download Connection info

IBM Cloud Download Connection info

In order to remotely connect to your IBM Cloud queue manager you will also need to be able to log in. As the MQ on IBM Cloud documentation describes here, you need the API key as your password to go with the user id ‘admin’. Follow the instructions on that page to obtain your API key.

Now you have all the pieces of information you need to set up any of the MQGem Software tools to administer your queue manager on IBM Cloud. As a reminder, these are the things you will need.

Item From where
Queue Manager Name You invented it when you created the queue manager. If you’ve forgotten it, it’s also in the text file you downloaded with the connection information.
Channel Name The “Administration channel name” can be found in the text file you downloaded with the connection information.
Connection Name This is built by concatenating the “Hostname” and “Listener port” details (with brackets round the port number) that can be found in the text file you downloaded with the connection information.
User ID This is ‘admin’
Password This is the API Key that you created by following the linked instructions.

On the pages that follow, we cover how to use the above information you have gathered in your table to configure each of our tools to connect to your IBM MQ in IBM Cloud Queue Manager. Go directly to the page for the tool you want to use, or page through each one in turn.

  1. MO71
  2. MQEdit
  3. MQSCX
  4. QLOAD

If you don’t have a licence and would like to try out any of our tools then send an email, noting which tool you’d like to try, to support@mqgem.com and a 1-month trial licence will be sent to you.

MQEdit recognises many message formats

Version 9.0.2 of MQEdit, our Live Parsing Editor for IBM MQ messages, added new formatters for JSON, FIX and CSV (OFS) messages. MQEdit already had formatters for standard MQ messages such as MQXQH, MQDLH and MQPCF and XML and EDIFACT messages.

MQEdit Formatted JSON Customer Record

MQEdit Formatting a JSON Customer Record

You can tie these new formatters to your messages just as you do user formats. Given it’s most likely that these will have an MQ Format of MQSTR, you should tie the formatter to the queue name, as follows.

queue APP1.CUSTOMER.ADDRESS
{
  formatter JSON;
}

Alternatively you can use the Formatter context menu when viewing a message to invoke the appropriate formatter.

MQEdit Formatter menu

MQEdit Formatter menu

You’ll also see another useful option in this menu, the “Contextual Newline”. This inserts the appropriate character into the message when you hit the enter key. Very useful for formats such as FIX where the newline character is the SOH (0x01) character.


The new version can be downloaded from the MQEdit Download Page. Any current licensed users of MQEdit can run the new version on their existing licence. If you don’t have a licence and would like to try out MQEdit then send an email to support@mqgem.com and a 1-month trial licence will be sent to you.

Running MQGem GUIs under WINE

MQGem with WINEWe spent the festive season partaking of a little wine which resulted in our recent announcement of the capability to run both the MQGem Software GUI applications, MO71 and MQEdit, on Intel Linux. This is achieved by running them under WINE. WINE is a fabulous piece of free software that comes from the WINE project. This software allows a huge range of Windows applications to run, virtually unchanged, on an Intel Linux machine. The software is not an emulator but rather translates Windows API calls to POSIX calls on the fly which means that it is fast and efficient. For most users, wine may even be already installed on your Linux system, for others, it will be as simple as issuing the command:-

yum install wine.i686

N.B. The MQGem GUIs are 32-bit Windows applications which is why you must install the wine.i686 package rather than letting the system decide which wine package you need based on the bitness of your O/S.

However, everybody’s Linux is just that little bit different. If you find when using the above command that it responds with:-

No package wine available.

then this means that the yum source repositories you currently use do not contain the WINE packages. The WINE packages are in the EPEL (Extra Packages for Enterprise Linux) repository which can be added to your yum as described in How can I install the packages from the EPEL software repository?

If the EPEL repository still refuses to play ball, there are a plethora of StackOverflow questions (with answers) to solve Cannot retrieve metalink for repository: epel.
Once you get WINE installed, there is one other piece of the puzzle. If you tried to run the mqmonntp.exe under WINE as-is, the GUI would run, but when you try to connect to MQ using it the following error would be shown.

Error connecting to 'MQG1' RC(2012) Environment error.

So before you do, you should download a new package from MQGem Software, an MQ WINE mapping layer. This is a shared object that maps from the MQI calls made that the Windows application expects to find in mqm.dll or mqic32.dll, and instead calls the locally installed entry points in the libmqm_r.so and libmqic_r.so libraries. These mapping packages are called mqm.dll.so and mqic32.dll.so.

So download the zipped tar file mq_wine.tgz, and untar the file using a command such as

tar -xvzf mq_wine.tgz

You need to put these libraries where WINE will find them. Your two choices are:

  • Put them in /usr/lib/wine
  • Put them where ever you like but ensure that the path is added to WINEDLLPATH environment variable.

Now download the latest version of MO71 or MQEdit and unzip it on your Linux system. We have made one or two minor changes to the programs to fix things we have discovered in our testing of them under WINE, so it is best if you start off with all the fixes to things we’ve found. If you already run MO71 with a Diamond or Enterprise licence then you can also copy your licence file across onto your Linux machine (assuming you’re on the same site for your Diamond licence). If you use an Emerald licence, then you’ll need one for this machine. If you’d like to try it out on Linux before you make your mind up to buy another Emerald, then please email support@mqgem.com to request a trial licence.

To run the program, use this command:-

wine mqmonntp [ MO71 parameters ]

Once you are comfortable that MO71 starts and runs correctly you may want to set up an icon on your desktop to issue this command and possibly run it in the background.

Cheers!

User Formats with String Messages

How many of you saw our post about the addition of User Formats to the message editor, MQEdit, and thought, “That doesn’t apply to me, all my messages are string messages (MQSTR)”?

Well, I have news for you. Not only does it apply to you, but it might be very useful!

Using string messages is a very common practice with MQ Applications. After all it keeps things nice and simple, MQ does all the work for you when messages need to be data converted from one platform to the other, and you don’t need to build data conversion exits that need to know the shape of your message formats.

However, it is rare that such a string message is completely free-form. There will be some kind of structure to the message. Sometimes this structure will be XML, JSON or EDIFACT (which are also supported by MQEdit) and sometimes this structure will be a set of fixed fields.

There are many advantages of using user formats when viewing or editing even your string messages.

  • You can see each field displayed with a label to indicate what it is.
  • It is easier to edit one field in the message without inadvertently changing another.
  • In the list of messages, you can choose which field(s) are shown rather than simply seeing the first n bytes of the string message. (This is done with the summary option)
  • You can have different detailed views of your message, by indicating that certain fields are for low, medium and high detail views. This can be very handy if there are a lot of fields in the message that you don’t often need to look at, and you want to de-clutter your view when looking at the message.
  • It is easier to see when messages are badly formed (see below).

Example of viewing a malformed message

As an example, imagine your application expects that the first 20 characters are the customer name; next there will be three 30 character chunks with the address lines 1, 2 and 3; and so on.

You can define such a fixed string message format to MQEdit as well, just like this:

struct CUSTADDR; Customer Address
{
  char Name[20];
  char Address1[30];
  char Address2[30];
  char Address3[30];
}

Now since your format is MQSTR, and probably all your MQSTR messages are different shapes, you can’t use the MQMD.Format field to tell MQEdit the shape of your messages, so instead, you tie the user format structure you just created, to your message, by tying it to the queue name like this:

queue APP1.CUSTOMER.ADDRESS
{
  struct CUSTADDR;
}

Then, instead of you having to remember what all the offsets inside the message are, when you are looking at what the receiving application contends is a badly formed message, you can instead have MQEdit display it to you making it easy to see the problem. Compare the two screen shots from MQEdit below. Which do you think is easier to use to spot what’s wrong with the message?

MQEdit String Message Unformatted

MQEdit showing a String Message Unformatted

MQEdit String Message Formatted

MQEdit showing a String Message Formatted

This view makes it really easy to see that the message is badly formed because there is a missing space and so the first address line is not starting at the correct offset.


If this feature interests you and you’d like to try it out for yourself, you can download MQEdit from the MQGem website and if you don’t currently have a licence, you may email support@mqgem.com to request a trial licence. Let us know what you think once you’ve had play with it.