Introduction to writing applications

Applications use command messages to communicate with the broker when they want to publish or subscribe to information. These messages use the WebSphere MQ Rules and Formatting Header (RF Header), which is described in Format of command messages. The content of each command message starts with an MQRFH structure. This structure contains a name/value string, which defines the type of command the message represents and any parameters associated with the command. In the case of a Publish command message, the name/value string is usually followed by the data to be published, in any format specified by the user. Broker responses to command messages also use the MQRFH structure.

The normal Message Queue Interface (MQI) calls (such as MQPUT and MQGET) can be used to put RF Header command messages to the broker queue, and to retrieve response messages and publications from their respective queues. The MQI is described in the WebSphere MQ Application Programming Guide. Most command messages are sent to the broker's control queue (SYSTEM.BROKER.CONTROL.QUEUE), but Publish and Delete Publication command messages are sent to the appropriate stream queue at the broker (for example, SYSTEM.BROKER.DEFAULT.STREAM).

Alternatively, you can use the WebSphere MQ Application Messaging Interface (AMI) to send messages to and receive them from the broker. The AMI constructs and interprets the fields in the RF Header, so you don't need to understand its structure. In addition, the application programmer is not concerned with details of how WebSphere MQ sends the message. These details (for instance, the queue name and fields in the message descriptor) are contained in AMI services and policies set up by a system administrator. The AMI is available as a SupportPac(TM).

This chapter describes the things that you need to know before you start writing a publisher or subscriber application. It discusses the following topics:

You can find more information about writing applications in the following chapters:

Sample programs to illustrate the techniques used are described in Sample programs.