Call the MQCreateProperties function to get a handle to a newly created properties object.
Call one of the MQSet...Property functions to set one of the connection properties described in Table 4–2 . At a minimum, you must specify the name of the host of the broker to which you want to connect and its port number.
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 an MQBool property, you call the MQSetBoolProperty function; and so on. Each function that sets a property requires that you pass a key name 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.
Once the connection is created with the properties you specify, you cannot change its properties. If you need to change connection properties after you have created a connection, you will need to destroy the old connection and its associated objects and create a new one with the desired properties. It is a good idea to think through the desired behavior before you create a connection.
The code sample below illustrates how you create a properties handle and how you use it for setting connection properties.
MQStatus status; MQPropertiesHandle propertiesHandle = MQ_INVALID_HANDLE; status = (MQCreateProperties(&propertiesHandle); status = (MQSetStringProperty(propertiesHandle, MQ_BROKER_HOST_PROPERTY, “localhost”)); status = (MQSetInt32Property(propertiesHandle, MQ_BROKER_PORT_PROPERTY, 7676)); status = MQSetStringProperty(propertiesHandle, MQ_CONNECTION_TYPE_PROPERTY, “TCP”));
The Message Queue C client runtime sets the connection properties that specify the name and version of the Message Queue product; you can retrieve these using the functionMQGetMetaData(). These properties are described at the end of Table 4–2, starting with MQ_NAME_PROPERTY.