Writing a data-conversion exit for MQSeries for OS/2 Warp

Follow these steps:

  1. Name your message format. The name must fit in the Format field of the MQMD. The Format name should not have leading blanks. Trailing blanks are ignored. The object's name must have no more than eight non-blank characters, because the Format is only eight characters long.

    A .DEF file called AMQSVFC2.DEF is also supplied in the samples directory, <drive:\directory>\MQM\TOOLS\C\SAMPLES. Take a copy of this file and rename it, for example, to MYFORMAT.DEF. Make sure that the name of the DLL being created and the name specified in MYFORMAT.DEF are the same. Overwrite the name FORMAT1 in MYFORMAT.DEF with the new format name.

    Remember to use this name each time you send a message.

  2. Create a structure to represent your message. See Valid syntax for an example.
  3. Run this structure through the crtmqcvx command to create a code fragment for your data-conversion exit.

    The functions generated by the crtmqcvx command use macros which are written assuming that all structures are packed; they should be amended if this is not the case.

  4. Take a copy of the supplied skeleton source file, AMQSVFC0.C, renaming it to the name of your message format that you decided on in step 1 (that is, MYFORMAT.C in this example). AMQSVFC0.C is in <drive:\directory>\MQM\TOOLS\C\SAMPLES (where <drive:\directory> was specified at installation).

    The skeleton includes a sample header file AMQSVMHA.H in the same directory. Make sure that your include path points to this directory to pick up this file.

    The AMQSVMHA.H file contains macros that are used by the code generated by the crtmqcvx command. If the structure to be converted contains character data, then these macros call MQXCNVC.

  5. Find the following comment boxes in the source file and insert code as described:
    1. Towards the bottom of the source file, a comment box starts with:
        /* Insert the functions produced by the data-conversion exit */
      

      Here, insert the code fragment generated in step 3.

    2. Near the middle of the source file, a comment box starts with:
        /* Insert calls to the code fragments to convert the format's */
      

      This is followed by a commented-out call to the function ConverttagSTRUCT.

      Change the name of the function to the name of the function you added in step 5a above. Remove the comment characters to activate the function. If there are several functions, create calls for each of them.

    3. Near the top of the source file, a comment box starts with:
        /* Insert the function prototypes for the functions produced by */
      

      Here, insert the function prototype statements for the functions added in step 5a above.

  6. Resolve this call by linking the routine with the library MQMVX.LIB, in the directory <drive:\directory>\MQM\TOOLS\LIB.
  7. Create the following command file:
      icc /Ge- /I<drive:\directory>\mqm\tools\c\samples  \
      /I<drive:\directory>\mqm\tools\c\include MYFORMAT.C   \
      <drive:\directory>\mqm\tools\lib\mqm.lib MYFORMAT.DEF  \
      <drive:\directory>\mqm\tools\lib\mqmvx.lib
    

    where <drive:\directory> is specified at installation.

    Issue the command file to compile your exit as a DLL file.

  8. Place the output in the \mqm\exits subdirectory. The path used to look for the data-conversion exits is given in the qm.ini file as DefaultExitPath. This path is set for each queue manager and the exit will only be looked for in that path or paths.

Notes:

  1. If CVTMQCVX uses packed structures, all WebSphere MQ applications must be compiled in this way.

  2. Data-conversion exit programs must be re-entrant.

  3. MQXCNVC is the only MQI call that may be issued from a data-conversion exit.


© IBM Corporation 1993, 2002. All Rights Reserved