Writing a data-conversion exit program for WebSphere MQ for iSeries
Follow these steps:
- Name your message format. The name must fit in the Format field of the MQMD. The Format name must 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 that you send a message (our example uses the name Format).
- Create a structure to represent your message. See Valid syntax for an example.
- 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; amended them if this is not the case.
- Take a copy of the supplied skeleton source file, QMQMSAMP/QCSRC(AMQSVFC4) and rename it. (Our example uses the name EXIT_MOD.)
- Find the following comment boxes in the source file and insert code as described:
- Toward 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.- 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 that you added in step 5.a above. Remove the comment characters to activate the function. If there are several functions, create calls for each of them.
- 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 5.a above.
If the message contains character data, the generated code calls MQXCNVC; this can be resolved by binding the service program QMQM/LIBMQM.
- Compile the source module, EXIT_MOD, as follows:
CRTCMOD MODULE(library/EXIT_MOD) + SRCFILE(QCSRC) + TERASPACE(*YES *TSIFC)- 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. Use the LIBMQM_R library 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)- 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.
- If CVTMQMDTA uses packed structures, all WebSphere MQ applications must use the _Packed qualifier.
- Data-conversion exit programs must be reentrant.
- MQXCNVC is the only MQI call that can be issued from a data-conversion exit.
- Compile the exit program with the user profile compiler option set to *USER, so that the exit runs with the authority of the user.
- Teraspace memory enablement is required for all user exits with WebSphere MQ for iSeries™; specify TERASPACE(*YES *TSIFC) in the CRTCMOD and CRTBNDC commands.
Parent topic:
Writing data-conversion exits
fg13110_