Sun Java System Message Queue 4.3 Developer's Guide for C Clients

ProcedureTo Set Up a Message Queue C Client to Produce Messages

  1. Call the MQCreateProperties function to get a handle to a properties object.

  2. Use one or more of the MQSet...Property functions to set connection properties that specify the name of the broker, its port number, and its behavior.

  3. Use the MQCreateConnection function to create a connection.

  4. Use the MQCreateSession function to create a session and to specify its acknowledge mode and its receive mode. If the session will be used only for producing messages, use the receive mode MQ_SESSION_SYNC_RECEIVE to avoid creating a thread for asynchronous message delivery.

  5. Use the MQCreateDestination function to specify a physical destination on the broker. The destination name you specify must be the same as the name of the physical destination.

  6. Use the MQCreateMessageProducer function or the MQCreateMessageProducerForDestination function to create a message producer. (If you plan to send a lot of messages to the same destination, you should use the MQCreateMessageProducerForDestination function.)

  7. Use the MQCreateBytesMessage function or the MQCreateTextMessage function to get a newly created message handle.

  8. Call the MQCreateProperties function to get a handle to a properties object that will describe the message header properties. This is only required if you want to set a message header property.

  9. Use one or more of the MQSet...Property functions to set properties that specify the value of the message header properties you want to set.

  10. Use the MQSetMessageHeaders function, passing a handle to the properties object you created in Step 8 and Step 9.

  11. Repeat Step 8 if you want to define custom message properties, and then use the MQSetMessageProperties function to set these properties for your message.

  12. Use the MQSetMessageReplyTo function if you want to specify a destination where replies to the message are to be sent.

  13. Use one of the MQSendMessage... functions to send the message.