The IBM MQ Object Model

The IBM MQ Object Model consists of classes, methods and properties.

The IBM MQ Object Model consists of:

  • Classes representing familiar IBM MQ concepts such as queue managers, queues, and messages.
  • Methods on each class corresponding to MQI calls.
  • Properties on each class corresponding to attributes of IBM MQ objects.

When creating an IBM MQ application using the IBM MQ Object Model, you create instances of these classes in the application. An instance of a class in object-oriented programming is called an object. When an object has been created, you interact with the object by examining or setting the values of the object's properties (the equivalent of issuing an MQINQ or MQSET call), and by making method calls against the object (the equivalent of issuing the other MQI calls).


Classes

The IBM MQ Object Model provides the following base set of classes.

The actual implementation of the model varies slightly between the different supported object-oriented environments.

    MQQueueManager
    An object of the MQQueueManager class represents a connection to a queue manager. It has methods to Connect(), Disconnect(), Commit(), and Backout() (the equivalent of MQCONN or MQCONNX, MQDISC, MQCMIT, and MQBACK). It has properties corresponding to the attributes of a queue manager. Accessing a queue manager attribute property implicitly connects to the queue manager if not already connected. Destroying an MQQueueManager object implicitly disconnects from the queue manager.

    MQQueue
    An object of the MQQueue class represents a queue. It has methods to Put() and Get() messages to and from the queue (the equivalent of MQPUT and MQGET). It has properties corresponding to the attributes of a queue. Accessing a queue attribute property, or issuing a Put() or Get() method call, implicitly opens the queue (the equivalent of MQOPEN). Destroying an MQQueue object implicitly closes the queue (the equivalent of MQCLOSE).

    MQTopic
    An object of the MQTopic class represents a topic. It has methods to Put() (publish) and Get() (receive or subscribe) messages to and from the topic (the equivalent of MQPUT and MQGET). It has properties corresponding to the attributes of a topic. An MQTopic object can only be accessed for publication or subscription, not both simultaneously. When used for receiving messages the MQTopic object can be created with an unmanaged or managed subscription and as a durable or non-durable subscriber - multiple overloaded constructors are provided for these differing scenarios.

    MQMessage
    An object of the MQMessage class represents a message to be put on a queue or got from a queue. It contains a buffer, and encapsulates both application data and MQMD. It has properties corresponding to MQMD fields, and methods that allow you to write and read user data of different types (for example, strings, long integers, short integers, single bytes) to and from the buffer.

    MQPutMessageOptions
    An object of the MQPutMessageOptions class represents the MQPMO structure. It has properties corresponding to MQPMO fields.

    MQGetMessageOptions
    An object of the MQGetMessageOptions class represents the MQGMO structure. It has properties corresponding to MQGMO fields.

    MQProcess
    An object of the MQProcess class represents a process definition (used with triggering). It has properties that represent the attributes of a process definition.

    MQDistributionList
    An object of the MQDistributionList class represents a distribution list (used to send multiple messages with a single MQPUT). It contains a list of MQDistributionListItem objects.

    MQDistributionListItem
    An object of the MQDistributionListItem class represents a single distribution list destination. It encapsulates the MQOR, MQRR, and MQPMR structures, and has properties corresponding to the fields of these structures.


Object references

In an IBM MQ program that uses the MQI, IBM MQ returns connection handles and object handles to the program.

These handles must be passed as parameters on subsequent IBM MQ calls. With the IBM MQ Object Model, these handles are hidden from the application program. Instead, the creation of an object from a class results in an object reference being returned to the application program. It is this object reference that is used when making method calls and property accesses against the object.


Return codes

Issuing a method call or setting a property value results in return codes being set.

These return codes are a completion code and a reason code, and are themselves properties of the object. The values of completion code and reason code are the same as those defined for the MQI, with some extra values specific to the object-oriented environment.