JavaScript is required to for searching.
Skip Navigation Links
Exit Print View
Oracle GlassFish Server Message Queue 4.5 Developer's Guide for C Clients
search filter icon
search icon

Document Information

Preface

1.  Introduction

2.  Using the C API

Message Queue C Client Setup Operations

To Set Up a Message Queue C Client to Produce Messages

To Set Up a Message Queue C Client to Consume Messages Synchronously

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

Working With Properties

Setting Connection and Message Properties

To Set Properties for a Connection

Getting Message Properties

To Iterate Through a Properties Handle

Working With Connections

Defining Connection Properties

Connection Handling

Reliability

Flow Control

Working With Secure Connections

Configuring the Client for Secure Communication

Verification Using Fingerprints

Coordinating NSS Initialization

Shutting Down Connections

Working With Sessions and Destinations

Creating a Session

Transacted Sessions

Message Acknowledgement

Receive Mode

Managing a Session

Creating Destinations

Programming Domains

Auto-Created Destinations

Temporary Destinations

Getting Information About Destinations

Working With Messages

Composing Messages

Message Header

Message Body Types

Composing the Message

Sending a Message

Receiving Messages

Working With Consumers

Receiving a Message Synchronously

Receiving a Message Asynchronously

Processing a Message

Working With Distributed Transactions

Message Queue Resource Manager Information

Programming Examples

Error Handling

To Handle Errors in Your Code

Memory Management

Logging

3.  Client Design Issues

4.  Reference

A.  Message Queue C API Error Codes

Index

Message Queue C Client Setup Operations

The general procedures for producing and consuming messages are introduced below. The procedures have a number of common steps which need not be duplicated if a client is both producing and consuming messages.

To 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.

To Set Up a Message Queue C Client to Consume Messages Synchronously

  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 receive mode. Specify MQ_SESSION_SYNC_RECEIVE for a synchronous session.
  5. Use the MQCreateDestination function to specify a destination on the broker from which the consumer is to receive messages. The destination name you specify must be the same as the name of the physical destination.
  6. Use the MQCreateMessageConsumer function or the MQCreateDurableMessageConsumer function to create a consumer.
  7. Use the MQStartConnection function to start the connection.
  8. Use one of the MQReceiveMessage... functions to start message delivery.

To 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.