Programming hints and tips

The following hints and tips are in no significant order. They are subjects that, if relevant to the work you are doing, might save you time.

Message Descriptor properties

If you manipulate message descriptor properties in a program, it can be better to use the hexadecimal equivalents of the fields.

The information in this section refers to the following properties:
  • AccountingToken
  • CorrelationId
  • GroupId
  • MessageId
Where an IBM® MQ application is the originator of a message and IBM MQ generates these properties, it is better to use the AccountingTokenHex, CorrelationIdHex, GroupIdHex, and MessageIdHex properties if you want to look at their values, or manipulate them in any way, including passing them back in a message to IBM MQ. The reason for this is that IBM MQ generated values are strings of bytes that have any value from 0 through 255 inclusive, they are not strings of printable characters.

Where your MQAX script is the originator of a message you can use either the AccountingToken, CorrelationId, GroupId, and MessageId properties or their Hex equivalents.

IBM MQ constants

IBM MQ constants are provided as members of the enum IBM MQ in library MQAX200.

IBM MQ string constants

IBM MQ string constants are not available when using IBM MQ Automation Classes for ActiveX. You must use the explicit character string for those shown in the following list and any others you might need. The commands must be padded to eight characters using spaces:

Table 1. IBM MQ string constants and their corresponding character strings.
String constant Corresponding character string
MQFMT_NONE " "
MQFMT_ADMIN "MQADMIN "
MQFMT_CHANNEL_COMPLETED "MQCHCOM "
MQFMT_CICS "MQCICS "
MQFMT_COMMAND_1 "MQCMD1 "
MQFMT_COMMAND_2 "MQCMD2 "
MQFMT_DEAD_LETTER_HEADER "MQDEAD "
MQFMT_DIST_HEADER "MQHDIST "
MQFMT_EVENT "MQEVENT "
MQFMT_IMS "MQIMS "
MQFMT_IMS_VAR_STRING "MQIMSVS "
MQFMT_MD_EXTENSION "MQHMDE "
MQFMT_PCF "MQPCF "
MQFMT_REF_MSG_HEADER "MQHREF "
MQFMT_RF_HEADER "MQHRF "
MQFMT_STRING "MQSTR "
MQFMT_TRIGGER "MQTRIG "
MQFMT_WORK_INFO_HEADER "MQHWIH "
MQFMT_XMIT_Q_HEADER "MQXMIT "

Null string constants

The IBM MQ constants, used for the initialization of four MQMessage properties, MQMI_NONE (24 NULL characters), MQCI_NONE (24 NULL characters), MQGI_NONE (24 NULL characters), and MQACT_NONE (32 NULL characters), are not supported by IBM MQ Automation Classes for ActiveX. Setting them to empty strings has the same effect.

For example, to set the various IDs of an MQMessage to these values: mymessage. MessageId = "" mymessage. CorrelationId = "" mymessage. AccountingToken = ""

Receiving a message from IBM MQ

There are several ways of receiving a message from IBM MQ:
  • Polling by issuing a GET followed by a Wait, using the Visual Basic TIMER function.
  • Issuing a GET with the Wait option; you specify the wait duration by setting the WaitInterval property. Consider this when, even though you set your system up to run in multithreaded environment, the software running at the time might run only single threaded. This avoids your system locking up indefinitely.

    Other threads operate unaffected. However, if your other threads require access to IBM MQ, they require a second connection to IBM MQ using additional MQAX queue manager and queue objects.

Issuing a GET with the Wait option and setting the WaitInterval to MQWI_UNLIMITED causes your system to lock up until the GET call completes, if the process is single threaded.