WebSphere® MQ message queue access
EGL supports access of WebSphere® MQ (formerly MQSeries®) message queues on any of the target platforms.
- Use WebSphere® MQ-related EGL keywords such as add and get next on a record with the MQRecord stereotype; in this case, EGL hides details of WebSphere® MQ so you can focus on the business problem your code is addressing.
- Invoke EGL functions that call WebSphere® MQ commands directly, in which case some commands are available that are not supported by the EGL keywords.
You can mix the two approaches in a given program. However, best practice is to use one or the other approach exclusively.
Regardless of your approach, you can control various runtime conditions through options records, which are variables based on specific global BasicRecord parts. EGL passes these variables on calls to WebSphere® MQ. EGL provides a number of sample Record parts that you can use as the basis for options records.
- If you work with the EGL add and get next statements, you identify options records in the properties of the MQRecord part that are associated with the statement (see MQRecord properties). If you do not identify a particular options record, EGL uses a default.
- If you invoke the EGL functions that call WebSphere® MQ directly, you use options records as arguments when you invoke the functions. Defaults are not available in this case.
- An Introduction to Messaging and Queueing (GC33-0805-01)
- MQSeries® MQI Technical Reference (SC33-0850)
- MQSeries® Application Programming Guide (SC33-0807-10)
- MQSeries® Application Programming Reference (SC33-1673-06)
Connections
- An EGL add or get next statement that accesses a message queue.
- An invocation of the EGL function MQCONN or MQCONNX.
You can access only one connecting queue manager at a time; however, you can access multiple queues that are under the control of the connecting queue manager. If you wish to connect directly to a queue manager other than the current connecting queue manager, you must disconnect from the first queue manager by invoking MQDISC, then connect to the second queue manager by invoking add, get next, MQCONN, or MQCONNX.
You can also access queues that are under the control of a remote queue manager, which is a queue manager with which the connecting queue manager can interact. Access between the two queue managers is possible only if WebSphere® MQ itself is configured to allow for that access.
Access to the connecting queue manager is terminated when you invoke MQDISC or when your code ends.
Include message in transaction
- An EGL get next statement (or an EGL MQGET invocation) removes a message only when a commit occurs
- The message placed on a queue by an EGL add statement (or an EGL MQPUT invocation) is visible outside the unit of work only after a commit occurs
When queue-access statements are not in a unit of work, each change to a message queue is committed immediately.
- For MQGET, MQGMO_SYNCPOINT
- For MQPUT, MQPMO_SYNCPOINT
- For MQGET, MQGMO_NO_SYNCPOINT
- For MQPUT, MQPMO_NO_SYNCPOINT
When your code ends a unit of work, EGL commits or rolls back all recoverable resources that are accessed by your program, including databases, message queues, and recoverable files. This outcome occurs whether you use the system functions (sysLib.commit, sysLib.rollback) or the EGL calls to WebSphere® MQ (MQCMIT, MQBACK); the appropriate EGL system function is invoked in either case.
A rollback occurs if an EGL program terminates early because of an error.
Customization
You can customize your interaction with WebSphere® MQ rather than relying on the default processing of add and get next statements.
- records.egl
- Contains BasicRecord parts that are the source for options records; also includes structure parts that those records use and that support your development of custom options records.
- functions.egl
- Contains two sets of functions:
- WebSphere® MQ command functions, which access WebSphere® MQ directly.
- Initialization functions, which you can use to place initial values in the options records that are used in your program.
- mqrcode.egl, mqrc.egl, mqvalue.egl
- Contains a set of EGL DataTable parts that are used by the command and initialization functions.
You must carry out the following tasks:
- Import the files into an EGL project from the following directory:
sharedInstallationDir\plugins\ com.ibm.etools.egl.resources_version\MqReusableParts- sharedInstallationDir
- The shared product installation directory, such as C:\Program Files\IBM\SDP70Shared. If you installed and kept a Rational® Developer product before installing the product that you are using now, you might need to specify the directory from the earlier installation.
- version
- The latest version of the plugin; for example, "7.0.100.RFB_20080711_1614".
- To make the parts more easily available to your program, write
one or more EGL import statements in the file that contains your program.
If the files to be imported reside in a project other than the one
in which you are developing code, make sure that your project references
the other project.
For details, see Import and use statements.
- In your program, declare global variables:
- Include use declarations for the mqrc, mqrcode, and mqvalue DataTables.
- For each options record that you wish to pass to WebSphere® MQ, declare a basic record that uses an options record part as a typedef. For details on each part, see Options records for MQRecords.
- In your function, initialize the options records that you intend to pass to WebSphere® MQ by invoking the imported EGL initialization function for each record. Each function has the name of a Record part followed by _INIT, for example, MQGMO_INIT.
- Set values for the fields in the options records. The mqvalue
DataTable contains a single row of fields, each of which corresponds
to a symbol that is described in the WebSphere® MQ documentation. You can set
a value for a field in an option record by using one of the fields
in the mqvalue DataTable, as in the following example:
mqgmo.options = mqvalue.mqgmo_lock[1];You can set a numeric field in an option record to a combination of values by adding the values, as in the following example:mqgmo.options = mqvalue.mqgmo_lock[1] + mqvalue.mqgmo_accept_truncated_msg[1] + mqvalue.mqgmo_browse_first[1]; - The details of when you need to generate tables depend on whether your target program language is COBOL or Java™. To generate all the data tables that are used in your program, allow the build descriptor option genTables to default to YES. For more information, see DataTable part.
Features supported only for COBOL
- Triggering
- Distribution lists