Developing C++ applications
IBM MQ provides C++ classes equivalent to IBM MQ objects and some additional classes equivalent to the array data types. It provides a number of features not available through the MQI.
IBM WebSphere MQ Version 7.0, enhancements to the IBM MQ programming interfaces are not applied to the C++ classes.
IBM MQ C++ provides the following features:- Automatic initialization of IBM MQ data structures.
- Just-in-time queue manager connection and queue opening.
- Implicit queue closure and queue manager disconnection.
- Dead-letter header transmission and receipt.
- IMS bridge header transmission and receipt.
- Reference message header transmission and receipt.
- Trigger message receipt.
- CICSĀ® bridge header transmission and receipt.
- Work header transmission and receipt.
- Client channel definition.
The following Booch class diagrams show that all the classes are broadly parallel to those IBM MQ entities in the procedural MQI (for example using C) that have either handles or data structures. All classes inherit from the ImqError class (see ImqError C++ class ), which allows an error condition to be associated with each object.
To interpret Booch class diagrams correctly, be aware of the following conventions:- Methods and noteworthy attributes are shown below the class name.
- A small triangle within a cloud denotes an abstract class.
- Inheritance is denoted by an arrow to the parent class.
- An undecorated line between clouds denotes a cooperative relationship between classes.
- A line decorated with a number denotes a referential relationship between two classes. The number indicates the number of objects that can participate in a particular relationship at any one time.
- The ImqBinary class (see ImqBinary C++ class ), which encapsulates byte arrays such as MQBYTE24.
- The ImqBoolean data type, which is defined as typedef unsigned char ImqBoolean.
- The ImqString class (see ImqString C++ class ), which encapsulates character arrays such as MQCHAR64.
Entities with data structures are subsumed within appropriate object classes. Individual data structure fields (see C++ and MQI cross-reference ) are accessed with methods.
Entities with handles come under the ImqObject class hierarchy (see ImqObject C++ class ) and provide encapsulated interfaces to the MQI. Objects of these classes exhibit intelligent behavior that can reduce the number of method invocations required relative to the procedural MQI. For example, we can establish and discard queue manager connections as required, or we can open a queue with appropriate options, then close it.
The ImqMessage class (see ImqMessage C++ class ) encapsulates the MQMD data structure and also acts as a holding point for user data and items (see Reading messages in C++ ) by providing cached buffer facilities. We can provide fixed-length buffers for user data and use the buffer many times. The amount of data present in the buffer can vary from one use to the next. Alternatively, the system can provide and manage a buffer of flexible length. Both the size of the buffer (the amount available for receipt of messages) and the amount actually used (either the number of bytes for transmission or the number of bytes actually received) become important considerations.