Oracle GlassFish Message Queue 4.4.2 Developer's Guide for C Clients

MQSendMessageToDestinationExt

The MQSendMessageToDestinationExt function sends a message to the specified destination for the specified producer and allows you to set selected message header properties.


MQSendMessageToDestinationExt
          (const MQProducerHandle  producerHandle,
           const MQMessageHandle  messageHandle,
           const MQDestinationHandle  destinationHandle,
           MQDeliveryMode msgDeliveryMode,
           MQInt8 msgPriority,
           MQInt64 msgTimeToLive);

Return Value

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

Parameters

producerHandle

The handle to the producer sending this message. This handle is passed back to you when you call the MQCreateMessageProducer() function.

messageHandle

A handle to the message you want to send.

destinationHandle

A handle to the destination where you want to send the message.

msgDeliveryMode

An enum of either MQ_PERSISTENT_DELIVERY or MQ_NONPERSISTENT_DELIVERY.

msgPriority

A integer value of 0 through 9; 0 being the lowest priority and 9 the highest.

msgTimeToLive

An integer value specifying in milliseconds how long the message will live before it expires. When a message is sent, its expiration time is calculated as the sum of its time-to-live value and current GMT. A value of 0 indicates that the message will never expire.

The MQSendMessageToDestinationExt function sends the specified message on behalf of the specified producer to the specified destination. Use this function if you want to change the default values for the message header properties as shown below:

Property

Default value

msgDeliveryMode

MQ_PERSISTENT_DELIVERY

msgPriority

4

msgTimeToLive

0, meaning no expiration limit

If these default values suit you, you can use the MQSendMessageToDestination() function to send the message.

You cannot use this function with a producer that is created with a specified destination.

You can set the broker property MQ_ACK_ON_PRODUCE_PROPERTY to make sure that the message has reached its destination on the broker:

Note that “acknowledgement” in this case is not programmatic but internally implemented. That is, the client thread is blocked and does not return until the broker acknowledges messages it receives.

Common Errors

MQ_PRODUCER_HAS_DEFAULT_DESTINATION
MQ_INVALID_PRIORITY
MQ_INVALID_DELIVERY_MODE
MQ_PRODUCER_CLOSED
MQ_SESSION_CLOSED
MQ_BROKER_CONNECTION_CLOSED
MQ_THREAD_OUTSIDE_XA_TRANSACTION
MQ_XA_SESSION_NO_TRANSATION