Writing a data-conversion exit for WebSphere MQ on UNIX systems
Follow these steps:
- Name your message format. The name must fit in the Format field of the MQMD, and be in uppercase, for example, MYFORMAT. The Format name must 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. Remember to use this name each time that you send a message.
- Create a structure to represent your message. See Valid syntax for an example.
- 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 that assume that all structures are packed; amend them if this is not the case.
- Copy the supplied skeleton source file, renaming it to the name of your message format that you set in step 1. The skeleton source file, and the copy, are read-only.
The skeleton source file is called amqsvfc0.c.
- On WebSphere MQ for AIX, a skeleton export file called amqsvfc.exp is also supplied. Copy this file, renaming it to MYFORMAT.EXP.
- The skeleton includes a sample header file, amqsvmha.h, in the directory /usr/mqm/inc (on AIX) or /opt/mqm/inc (on other UNIX systems). 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, these macros call MQXCNVC.
- 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 7.a. 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 3 above.
- Resolve this call by linking the routine with the library libmqm. For threaded programs, the routine must be linked with the library libmqm_r (AIX and HP-UX only).
- Compile your exit as a shared library, using MQStart as the entry point. To do this, see Compiling data-conversion exits on UNIX and Linux.
- Place the output in the default system directory, /var/mqm/exits, to ensure that it can be loaded when required. The path used to look for the data-conversion exits is given in the qm.ini file. This path can be set for each queue manager and the exit is only looked for in that path or paths.
- If crtmqcvx uses packed structures, all WebSphere MQ applications must be compiled in this way.
- Data-conversion exit programs must be reentrant.
- MQXCNVC is the only MQI call that can be issued from a data-conversion exit.
Parent topic:
Writing data-conversion exits
fg13130_