Data Types summarizes the data types defined by the Message Queue C API. The table lists data types in alphabetical order and provides cross references for types that require broader discussion.
Note that Message Queue data types designated as handles map to opaque structures (objects). Please do not attempt to dereference these handles to get to the underlying objects. Instead, use the functions provided to access the referenced objects.
Table 4–1 Message Queue C-API Data Type Summary
Message Queue Type |
Description |
|
---|---|---|
ConstMQString |
A constant MQString. |
|
MQAckMode |
An enum used to specify the acknowledgement mode of a session. Possible values include the following:
See Acknowledge Modes for more information. |
|
MQBool |
A boolean that can assume one of two values:
|
|
MQChar |
char type. |
|
MQConnectionHandle |
A handle used to reference a Message Queue connection. You get this handle when you call the MQCreateConnection() function. |
|
MQConsumerHandle |
A handle used to reference a Message Queue consumer. A consumer can be durable, nondurable and synchronous, or asynchronous. You get this handle when you call one of the functions used to create consumers. See Receiving Messages for more information. |
|
MQDeliveryMode |
An enum used to specify whether a message is sent persistently:
You specify this value with the MQSendMessageExt() function or the MQSendMessageToDestinationExt() function. |
|
MQDestinationHandle |
A handle used to reference a Message Queue destination. You get this handle when you call the MQCreateDestination() function or the MQCreateTemporaryDestination() function. |
|
MQDestinationType |
An enum used to specify the type of a destination:
You set the destination type using the MQCreateDestination function or the MQCreateTemporaryDestination() function. |
|
MQError |
A 32-bit unsigned integer. |
|
MQConnectionExceptionListenerFunc |
The type of a callback function used for connection exception handling. For more information, see Callback Type for Connection Exception Handling. |
|
MQFloat32 |
A 32-bit floating-point number. |
|
|
A 64-bit floating-point number. |
|
MQInt16 |
A 16-bit signed integer. |
|
MQInt32 |
A 32-bit signed integer. |
|
MQInt64 |
A 64-bit signed integer. |
|
MQInt8 |
An 8-bit signed integer. |
|
MQMessageHandle |
A handle used to reference a Message Queue message. You get this handle when you call the MQCreateBytesMessage() function, or the MQCreateTextMessage function, or on receipt of a message. |
|
MQMessageListenerFunc |
The type of a callback function used for asynchronous message receipt. For more information, see Callback Type for Asynchronous Messaging. |
|
MQMessageType |
An enum passed back by the MQGetMessageType and used to specify the type of a message; possible values include the following:
|
|
MQProducerHandle |
A handle used to reference a Message Queue producer. You get this handle when you call MQCreateMessageProducer or MQCreateMessageProducerForDestination. |
|
MQPropertiesHandle |
A handle used to reference Message Queue properties. You use this handle to define or read connection properties and message headers or message properties. See Working With Properties for more information. |
|
MQReceiveMode |
An enum used to specify whether consumers are synchronous or asynchronous. It can be one of the following:
See MQCreateSession for more information. |
|
MQSessionHandle |
A handle used to reference a Message Queue session. You get this handle when you call the MQCreateSession() function. |
|
MQStatus |
A data type returned by nearly all functions defined in mqcrt.h. See Error Handling for more information on how you handle errors returned by Message Queue functions. |
|
MQString |
A null terminated UTF-8 encoded character string |
|
MQType |
An enum used to return the type of a single property; possible values include the following:
|
When you create a connection using the MQCreateConnection function, you must pass a handle to an object of type MQPropertiesHandle. The following table lists and describes the key values that define each property. The procedure that follows the table explains how you set the properties referenced by this handle.
Table 4–2 Connection Properties
Key Name |
Description |
|
---|---|---|
|
An MQString specifying the transport protocol of the connection service used by the client. Supported types are TCP or SSL. Default: TCP |
|
|
A 32-bit integer specifying the maximum time in milliseconds that the client runtime will wait for any broker acknowledgement before returning an MQ_TIMEOUT_EXPIRED error. A value of 0 means there is no time-out. Default: 0 |
|
|
An MQString specifying the broker host name to which to connect. If you set the property MQ_SSL_BROKER_IS_TRUSTED to false, the value you specify for the property MQ_BROKER_HOST_PROPERTY must match the CN (common name) of the broker’s certificate. No default. |
|
|
A 32-bit integer specifying the interval (in seconds) that the connection can remain idle before the client runtime tests the connection by pinging the broker. (The exact amount of time it takes for the ping to detect connection failure varies with the system’s TCP configuration.) A ping interval that is <= 0 turns off the ping for the connection. The minimum allowable interval is 1 second. This prevents an application from setting the interval to a value that would affect performance. The ping interval is logged at the INFO level by the C client runtime when a connection is created. Default: 30 seconds |
|
|
A 32-bit integer specifying the broker’s primary port number. No default. |
|
|
An MQBool specifying whether the producing client waits for broker acknowledgement of receipt of message from the producing client. If set to MQ_TRUE, the broker acknowledges receipt of all messages (persistent and non-persistent) from the producing client, and the producing client thread will block waiting for those acknowledgements. If set to MQ_FALSE, broker does not acknowledge receipt of any message (persistent or non-persistent) from the producing client, and the producing client thread will not block waiting for broker acknowledgements. Default: the broker acknowledges receipt of persistent messages only from the producing client, and the producing client thread will block waiting for those acknowledgements. |
|
|
An MQBool specifying whether the broker confirms (acknowledges) consumer acknowledgements. A consumer acknowledgement can be initiated either by the client’s session or by the consuming client, depending on the session acknowledgement mode (see Acknowledge Modes). If the session’s acknowledgement mode is MQ_DUPS_OK_ACKNOWLEDGE, this flag has no effect. If set to MQ_TRUE, the broker acknowledges all consuming acknowledgements, and the consuming client thread blocks waiting for these broker acknowledgements. If set to MQ_FALSE, the broker does not acknowledge any consuming client acknowledgements, and the consuming client thread will not block waiting for such broker acknowledgements. Default: MQ_TRUE For more information, see the discussion for the MQAcknowledgeMessages function and Message Acknowledgement. |
|
|
A 32-bit integer, greater than 0, specifying the number of Message Queue messages in a metered batch. When this number of messages is delivered from the broker to the client runtime, delivery is temporarily suspended, allowing any control messages that had been held up to be delivered. Payload message delivery is resumed upon notification by the client runtime, and continues until the count is again reached. Default: 100 |
|
|
An MQBool specifying whether the value MQ_CONNECTION_FLOW_LIMIT_PROPERTY is used to control message flow. Specify MQ_TRUE to use the value and MQ_FALSE otherwise. Default: MQ_FALSE |
|
|
A 32-bit integer, greater than 0, specifying the maximum number of unconsumed messages the client runtime can hold for each connection. Note however, that unless MQ_CONNECTION_FLOW_LIMIT_ENBABLED_PROPERTY is MQ_TRUE, this limit is not checked. When the number of unconsumed messages held by the client runtime for the connection exceeds the limit, message delivery stops. It is resumed (in accordance with the flow metering governed by MQ_CONNECTION_FLOW_COUNT_PROPERTY) only when the number of unconsumed messages drops below the value set with this property. This limit prevents a consuming client that is taking a long time to process messages from being overwhelmed with pending messages that might cause it to run out of memory. Default: 1000 |
|
|
An MQ_Bool specifying whether the broker is trusted. Default: MQ_TRUE |
|
|
An MQ_Bool. If it is set to MQ_TRUE and if MQ_SSL_BROKER_IS_TRUSTED is MQ_FALSE, the broker’s certificate fingerprint is compared with the MQ_SSL_BROKER_CERT_FINGERPRINT property value in case of certificate authorization failure. If they match, the broker’s certificate is authorized for use in the SSL connection. Default: MQ_FALSE |
|
|
An MQString specifying the MD5 hash, in hex format, of the broker’s certificate. Default: NULL |
|
|
An MQString that specifies the name of the Message Queue product. This property is set by the runtime library. See MQGetMetaData for more information. |
|
|
An MQInt32 that specifies the version of the Message Queue product. This property is set by the runtime library. See MQGetMetaData for more information. |
|
|
An MQInt32 that specifies the major version of the Message Queue product. For example, if the version is 3.5.0.1, the major version would be 3. This property is set by the runtime library. See MQGetMetaData for more information. |
|
|
An MQInt32 that specifies the minor version of the Message Queue product. For example, if the version is 3.5.0.1, the minor version would be 5. This property is set by the runtime library. See MQGetMetaData for more information. |
|
|
An MQInt32 that specifies the micro version of the Message Queue product. For example, if the version is 3.5.0.1, the micro version would be 0. This property is set by the runtime library. See MQGetMetaData for more information. |
|
|
An MQInt32 that specifies the service pack version of the Message Queue product. For example, if the version is 3.5.0.1, the service pack version would be 1. This property is set by the runtime library. See MQGetMetaData for more information. |
|
|
An MQInt32 that specifies the update release version of the Message Queue product. For example, if the version is 3.7 UR1, the update release value would be 1. This property is set by the runtime library. See MQGetMetaData for more information. |
Call the MQCreateProperties function to get a handle to a newly created properties object
Call a function to set one of the connection properties listed in Table 4–2.
Which function you call depends on the type of the property you want to set; for example, to set an MQString property, you call the MQSetStringProperty function; to set a MQBool property, you call the MQSetBoolProperty function; and so on. Each function that sets a property requires that you pass a key name (constant) and value; these are listed and described in Table 4–2.
When you have set all the properties you want to define for the connection, you can then create the connection, by calling the MQCreateConnection function.
The runtime library sets the connection properties that specify the name and version of the Message Queue product; you can retrieve these using the MQGetMetaData function. These properties are described at the end of Table 4–2, starting with MQ_NAME_PROPERTY.
The Message Queue runtime supports reliable delivery by using transacted sessions or through acknowledgement options set at the session level. When you use the MQCreateSession function to create a session, you must specify an acknowledgement option for that session using the acknowledgeMode parameter. The value of this parameter is ignored for transacted sessions.
Table 4–3describes the effect of the options you can set using the acknowledgeMode parameter.
Table 4–3 acknowledgeMode Values
Enum |
Description |
|
---|---|---|
|
The session automatically acknowledges each message consumed by the client. This happens when one of the receive functions returns successfully, or when the message listener processing the message returns successfully. |
|
|
The client explicitly acknowledges all messages for the session that have been consumed up to the point when the MQAcknowledgeMessages function has been called. See the discussion of the function MQAcknowledgeMessages for additional information. |
|
|
The session acknowledges after ten messages have been consumed and does not guarantee that messages are delivered and consumed only once. |
|
|
This value is read only. It is set by the library if you have passed MQ_TRUE for the isTransacted parameter to the MQCreateSession function. It is returned to you by the MQGetAcknowledgeMode function if the session is transacted. |
When you call the MQCreateAsyncMessageConsumer() function or the MQCreateAsyncDurableMessageConsumer() function, you must pass the name of an MQMessageListenerFunc type callback function that is to be called when the consumer receives a message to the specified destination.
The MQMessageListenerFunc type has the following definition:
MQError (* MQMessageListenerFunc)( const MQSessionHandle sessionHandle, const MQConsumerHandle consumerHandle, MQMessageHandle messageHandle void * callbackData); |
The handle to the session to which this consumer belongs. The client runtime specifies this handle when it calls your message listener.
A handle to the consumer receiving the message. The client runtime specifies this handle when it calls your message listener.
A handle to the incoming message. The client runtime specifies this handle when it calls your message listener.
The void pointer that you passed to the function MQCreateAsyncMessageConsumer or the function MQCreateAsyncDurableMessageConsumer.
The body of a message listener function is written by the receiving client. Mainly, the function needs to process the incoming message by examining its header, body, and properties. The client is also responsible for freeing the message handle (either from within the handler or from outside the handler) by calling MQFreeMessage.
In addition, you should observe the following guidelines when writing the message listener function:
If you specify MQ_CLIENT_ACKNOWLEDGE as the acknowledge mode for the session, you must explicitly call the MQAcknowledgeMessages function to acknowledge messages that you have received. For more information, see the description of the function MQAcknowledgeMessages.
Do not try to close the session (or the connection to which it belongs) and consumer handle in the message listener.
It is possible for a message listener to return an error; however, this is considered a client programming error. If the listener discovers that the message is badly formatted or if it cannot process it for some other reason, it should handle the problem itself by re-directing it to an application-specific bad-message destination and process it later.
If the message listener does return an error, the client runtime will try to redeliver the message once if the session’s acknowledge mode is either MQ_AUTO_ACKNOWLEDGE or MQ_DUPS_OK_ACKNOWLEDGE .
The client runtime will call this function when a connection exception occurs.
The MQConnectionExceptionListenerFunc type has the following definition:
Void (* MQConnectionExceptionListenerFunc)( const MQConnectionHandle connectionHandle, MQStatus exception, void * callbackData); |
Parameters
The handle to the connection on which the connection exception occurred. The client runtime sets this handle when it calls the connection exception handler.
An MQStatus for the connection exception that occurred. The client runtime specifies this value when it calls the exception handler.
You can pass this status result to any functions used to handle errors to get an error code or error string. For more information, see Error Handling.
Whatever void pointer was passed as the listenerCallbackData parameter to the functionMQCreateConnection for more information.
The body of a connection exception listener function is written by the client. This function will only be called synchronously with respect to a single connection. If you install it as the connection exception listener for multiple connections, then it must be reentrant.
Do not try to close the session (or the connection to which it belongs) in the exception listener.