Basic messaging with IBM MQ
The most basic form of messaging with the Db2 MQ functions occurs when all database applications connect to the same Db2 database server. Clients can be local to the database server or distributed in a network environment.
In a simple scenario, client A invokes the MQSEND function to send a user-defined string to the location that is defined by the default service. Db2 executes the MQ functions that perform this operation on the database server. At some later time, client B invokes the MQRECEIVE function to remove the message at the head of the queue that is defined by the default service, and return it to the client. Db2 executes the MQ functions that perform this operation on the database server.
- Data collection
Information is received in the form of messages from one or more sources. An information source can be any application. The data is received from queues and stored in database tables for additional processing.
- Workload distribution
Work requests are posted to a queue that is shared by multiple instances of the same application. When an application instance is ready to perform some work, it receives a message that contains a work request from the head of the queue. Multiple instances of the application can share the workload that is represented by a single queue of pooled requests.
- Application signaling
In a situation where several processes collaborate, messages are often used to coordinate their efforts. These messages might contain commands or requests for work that is to be performed. For more information about this technique, see Application to application connectivity with IBM MQ.
- The Db2 client executes an MQSEND function call, specifying a target service that has been defined to be a remote queue on machine B.
- The MQ functions perform the work to send the message. The WebSphere MQ server on machine A accepts the message and guarantees that it will deliver it to the destination that is defined by the service and the current MQ configuration of machine A. The server determines that the destination is a queue on machine B. The server then attempts to deliver the message to the WebSphere MQ server on machine B, trying again as needed.
- The IBM MQ server on machine B accepts the message from the server on machine A and places it in the destination queue on machine B.
- A IBM MQ client on machine B requests the message at the head of the queue.