Writing a data-conversion exit program for WebSphere MQ for iSeries

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 embedded blanks, and 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. Remember to use this name each time you send a message (our example uses the name Format).
  2. Create a structure to represent your message. See Valid syntax for an example.
  3. Run this structure through the CVTMQMDTA command to create a code fragment for your data-conversion exit.

    The functions generated by the CVTMQMDTA command use macros that are shipped in the file QMQM/H(AMQSVMHA). These macros 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, QMQMSAMP/QCSRC(AMQSVFC4) and rename it. (Our example uses the name EXIT_MOD.)
  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.

    If the message contains character data, the generated code calls MQXCNVC; this can be resolved by binding the service program QMQM/LIBMQM.

  6. Compile the source module, EXIT_MOD, as follows:
      CRTCMOD MODULE(library/EXIT_MOD) +
      SRCFILE(QCSRC) +
      TERASPACE(*YES *TSIFC)
    
  7. Create/link the program.

    For nonthreaded applications, use the following:

      CRTPGM PGM(library/Format)  +
         MODULE(library/EXIT_MOD)  +
         BNDSRVPGM(QMQM/LIBMQM)  +
         ACTGRP(QMQM)  +
         USRPRF(*USER)
    

    In addition to creating the data-conversion exit for the basic environment, another is required in the threaded environment. This loadable object must be followed by _R. The LIBMQM_R library should be used to resolve calls to the MQXCNVC. Both loadable objects are required for a threaded environment.

      CRTPGM PGM(library/Format_R)  +
         MODULE(library/EXIT_MOD)  +
         BNDSRVPGM(QMQM/LIBMQM_R)  +
         ACTGRP(QMQM)  +
         USRPRF(*USER)
    
  8. Place the output in the library list for the WebSphere MQ job. It is recommended that, for production, data-conversion exit programs be stored in QSYS.

Notes:

  1. If CVTMQMDTA uses packed structures, all WebSphere MQ applications must use the _Packed qualifier.

  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.

  4. The exit program should be compiled with the user profile compiler option set to *USER, so that the exit runs with the authority of the user.

  5. Teraspace memory enablement is required for all user exits with WebSphere MQ for iSeries and TERASPACE(*YES *TSIFC) must be specified in the CRTCMOD and CRTBNDC commands.


© IBM Corporation 1993, 2002. All Rights Reserved