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

ProcedureTo Set Up a Message Queue C Client to Consume Messages Asynchronously

  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. Specify MQ_SESSION_ASYNC_RECEIVE for asynchronous message delivery.

  5. Use the MQCreateDestination function to specify a destination on the broker from which the consumer is to receive messages. The logical destination name you specify must be the same as the name of the physical destination.

  6. Write a callback function of type MQMessageListenerFunc that will be called when the broker starts message delivery. In the body of this callback function, use the functions described in Processing a Message , to process the contents of the incoming message.

  7. Use the MQCreateAsyncMessageConsumer function or the MQCreateAsyncDurableMessageConsumer function to create a consumer.

  8. Use the MQStartConnection function to start the connection and message delivery.