WebSphere MQ techniques
For a simple WebSphere MQ application, you need to decide which WebSphere MQ objects to use in your application, and which types of message you want to use. For a more advanced application, you may want to use some of the techniques introduced in the following sections.
Waiting for messages
A program that is serving a queue can await messages by:
- Making periodic calls on the queue to see whether a message has arrived (polling).
- Waiting until either a message arrives, or a specified time interval expires (see Waiting for messages).
- Setting a signal so that the program is informed when a message arrives (WebSphere MQ for z/OS only). For information about this, see Signaling.
Correlating replies
In WebSphere MQ applications, when a program receives a message that asks it to do some work, the program usually sends one or more reply messages to the requester. To help the requester to associate these replies with its original request, an application can set a correlation identifier field in the descriptor of each message. Programs should copy the message identifier of the request message into the correlation identifier field of their reply messages.
Setting and using context information
Context information is used for associating messages with the user who generated them, and for identifying the application that generated the message. Such information is useful for security, accounting, auditing, and problem determination.
When you create a message, you can specify an option that requests that the queue manager associates default context information with your message.
For more information on using and setting context information, see Message context.
Starting WebSphere MQ programs automatically
WebSphere MQ triggering enables a program to be started automatically when messages arrive on a queue. You can set trigger conditions on a queue so that a program is started to process that queue:
- Every time a message arrives on the queue
- When the first message arrives on the queue
- When the number of messages on the queue reaches a predefined number
For more information on triggering, see Chapter 14, Starting WebSphere MQ applications using triggers.
Triggering is just one way of starting a program automatically. For example, you can start a program automatically on a timer using non-WebSphere MQ facilities.
Generating WebSphere MQ reports
You can request the following reports within an application:
- Exception reports
- Expiry reports
- Confirm-on-arrival (COA) reports
- Confirm-on-delivery (COD) reports
- Positive action notification (PAN) reports
- Negative action notification (NAN) reports
These are described in Report messages.
Clusters and message affinities
Before starting to use clusters with multiple definitions for the same queue, examine your applications to see whether there are any that require an exchange of related messages. Within a cluster, a message may be routed to any queue manager that hosts an instance of the appropriate queue. Therefore, the logic of applications with message affinities may be upset.
For example, you may have two applications that rely on a series of messages flowing between them in the form of questions and answers. It may be important that all the questions are sent to the same queue manager and that all the answers are sent back to the other queue manager. In this situation, it is important that the workload management routine does not send the messages to any queue manager that just happens to host an instance of the appropriate queue.
You should attempt, where possible, to remove the affinities. Removing message affinities improves the availability and scalability of applications.
For more information see WebSphere MQ Queue Manager Clusters.
WebSphere is a trademark of the IBM Corporation in the United States, other countries, or both.
IBM is a trademark of the IBM Corporation in the United States, other countries, or both.