| home / infca / MQ Pub/Sub (navigation links) | The road to innovation isn't paved at all (Sun) |
| Pub | Sub | App | Broker | Links | End |
Publisher applications communicate with the broker using command messages in the RF Header format (or the equivalent functions in the Application Messaging Interface). Publishers can register with the broker before they start publishing information, they can register implicitly with their first publication, or they can choose not to register. When they have finished publishing information, they can deregister with the broker. They can also delete retained publications.
The publisher can send a Register Publisher command message to the broker's control queue (SYSTEM.BROKER.CONTROL.QUEUE) to indicate that a publisher will be, or is capable of, publishing data on one or more specified topics.
Subscriber applications need to register their interest in receiving publications with a broker. Send the Register Subscriber command message to the SYSTEM.BROKER.CONTROL.QUEUE to register as a subscriber.
To run the application on a single queue manager, first start the queue manager and then enter the following command:
This creates the appropriate queues on the queue manager. Then start the broker :
The results service program is started by entering the following:
You can now start one or more match simulators by entering the following command:
Before you can add a broker to the network, channels in both directions must exist between the queue manager that hosts the new broker and the queue manager that hosts the parent. Brokers use explicit addressing when sending messages to queues that reside on another queue manager. When the queue is opened by the broker, both the queue and queue manager names are specified. To facilitate multi-broker operation, this queue manager name must resolve to the appropriate transmission queue. The simplest method of achieving this is for the transmission queue to have the same name as the remote queue manager name.
To add a broker to the network, start the broker with the strmqbrk command specifying the name of the parent broker if appropriate. When the broker has been started with a parent named you cannot change the name of its parent, even when the broker is restarted. You cannot change the parent of a broker as part of normal operational procedures without disrupting service.
This example shows the sequence of commands for adding and deleting brokers in a network. Queue manager A is to host the parent broker and queue manager B is to host the child broker. Channels are defined between the two queue managers. Broker A is the parent broker, so this must be created first. Broker B is then created as a child broker of broker A. The sequence of commands to achieve this is as follows:
When both brokers are deleted, broker B must be deleted first, and broker A must be available for this to happen. Only when broker B has been deleted can broker A be deleted. The sequence of commands to achieve this is as follows.
Writing a simple publish/subscribe application connecting through MQ
|
|
|
|
Updated : 28/05/2008.
|
|