Implicit operations in C++

Several operations can occur implicitly, just in time, to satisfy the prerequisite conditions for the successful execution of a method. These implicit operations are connect, open, reopen, close, and disconnect. We can control connect and open implicit behavior using class attributes.


Connect

An ImqQueueManager object is connected automatically for any method that results in any call to the MQI (see C++ and MQI cross-reference ).


Open

An ImqObject object is opened automatically for any method that results in an MQGET, MQINQ, MQPUT, or MQSET call. Use the openFor method to specify one or more relevant open option values.


Reopen

An ImqObject is reopened automatically for any method that results in an MQGET, MQINQ, MQPUT, or MQSET call, where the object is already open, but the existing open options are not adequate to allow the MQI call to be successful. The object is temporarily closed using a temporary close options value of MQCO_NONE. Use the openFor method to add a relevant open option.

Reopen can cause problems in specific circumstances:

  • A temporary dynamic queue is destroyed when it is closed and can never be reopened.
  • A queue opened for exclusive input (either explicitly or by default) might be accessed by others in the window of opportunity during closure and reopening.
  • A browse cursor position is lost when a queue is closed. This situation does not prevent closure and reopening, but prevents subsequent use of the cursor until MQGMO_BROWSE_FIRST is used again.
  • The context of the last message retrieved is lost when a queue is closed.

If any of these circumstances occur or can be foreseen, avoid reopens by explicitly setting adequate open options before an object is opened (either explicitly or implicitly).

Set the open options explicitly for complex queue-handling situations results in better performance and avoids the problems associated with the use of reopen.


Close

An ImqObject is closed automatically at any point where the object state is no longer viable, for example if an ImqObject connection reference is severed, or if an ImqObject object is destroyed.


Disconnect

An ImqQueueManager is disconnected automatically at any point where the connection is no longer viable, for example if an ImqObject connection reference is severed, or if an ImqQueueManager object is destroyed. Parent topic: C++ language considerations