Sun GlassFish Message Queue 4.4 Developer's Guide for C Clients

MQCreateDestination

The MQCreateDestination function creates a a logical destination and passes a handle to it back to you.


MQCreateDestination(const MQSessionHandle sessionHandle
                 ConstMQString destinationName,
                 MQDestinationType destinationType,
                 MQDestinationHandle * destinationHandle);

Return Value

MQStatus. See the MQStatusIsError() function for more information.

Parameters

sessionHandle

The handle to the session with which you want to associate this destination.

destinationName

An MQString specifying the logical name of this destination. The library makes a copy of the destinationName string. See discussion below.

Destination names starting with “mq” are reserved and should not be used by clients.

destinationType

An enum specifying the destination type, either MQ_QUEUE_DESTINATION or MQ_TOPIC_DESTINATION.

destinationHandle

Output parameter for the handle to the newly created destination. You can pass this handle to functions sending messages or to message producers or consumers.

The MQCreateDestination function creates a logical destination and passes a handle to it back to you. Note that the Message Queue administrator has to also create a physical destination on the broker, whose name and type is the same as the destination created here, in order for messaging to happen. For example, if you use this function to create a queue destination called myMailQDest, the administrator has to create a physical destination on the broker named myMailQDest.

If you are doing development, you can simplify this process by turning on the imq.autocreate.topic or imq.autocreate.queue properties for the broker. If you do this, the broker automatically creates a physical destination whenever a message consumer or message producer attempts to access a non-existent destination. The auto-created destination will have the same name as the logical destination name you specified using the MQCreateDestination function. By default, the broker has the properties imq.autocreate.topic and imq.autocreate.queue turned on.

Common Errors

MQ_INVALID_DESTINATION_TYPE
MQ_SESSION_CLOSED