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

MQSendMessageExt

The MQSendMessageExt function sends a message using the specified producer and allows you to specify selected message header properties.


MQSendMessageExt
                (const MQProducerHandle producerHandle,
                 const MQMessageHandle messageHandle
                 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 by the MQCreateMessageProducerForDestination() function.

messageHandle

A handle to the message you want to send.

msgDeliveryMode

An enum

MQ_PERSISTENT_DELIVERY

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 he message will never expire.

The MQSendMessageExt function sends the specified message on behalf of the specified producer to the destination associated with the message producer. Use this function if you want to change the default values for the message header properties as shown in the next table.

Property

Default value

msgDeliveryMode

MQ_PERSISTENT_DELIVERY

msgPriority

4

msgTimeToLive

0, meaning no expiration limit

If you set these message headers using the MQSetMessageHeaders function before the send, they will be ignored when the message is sent. When the send completes, these message headers hold the values that are set by the send.

You cannot use this function with a producer that is created without 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 from the producing client.

Common Errors

MQ_PRODUCER_NO_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