4.3.1. Running the Fanout Examples
The example programs discussed in this section are found in /usr/share/doc/rhm-0.2/python/fanout. To run these programs, do the following:
Make sure that a qpidd broker is running:
$ ps -eaf | grep qpidd
If a broker is running, you should see the qpidd process in the output of the above command. If no broker is running, see the instructions in Chapter 3, Installing MRG Messaging.
In separate windows, start two or more fanout consumers or fanout listeners as follows:
$ python fanout_consumer.py
or
$ python listener.py
These programs each create a private queue, bind it to the amq.fanout exchange, and wait for messages to arrive on their queue.
In a separate window, publish a series of messages to the amq.fanout exchange by running fanout_producer.py, as follows:
$ python fanout_producer.py
This program has no output; the messages are routed to the message queue, as instructed by the binding.
Go to the windows where you are running consumers or listeners. You should see the following output for each listener or consumer:
message 0 message 1 message 2 message 3 message 4 message 5 message 6 message 7 message 8 message 9 That's all, folks!
Now let's take a look at the code for each of these programs. In each section, we will discuss only the code that must be added to the skeleton shown in Section 4.1, “Creating and Closing Sessions”.