6.5.1. Running the Fanout Examples
The example programs discussed in this section are found in /usr/share/doc/rhm-0.2/java/. Copy this directory to a location where you have write privileges. 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 the java directory, use runSample.sh to run the Consumer or Listener program, specifying a unique queue name, which must be “fanoutQueue1”, “fanoutQueue2”, or “fanoutQueue3”:
$ ./runSample.sh org.apache.qpid.example.jmsexample.fanout.Consumer fanoutQueue1 Using QPID_HOME: /usr/share/java/ Using QPID_SAMPLE: /usr/share/doc/rhm-0.2 Consumer: Setting an ExceptionListener on the connection as sample uses a MessageConsumer Consumer: Creating a non-transacted, auto-acknowledged session Consumer: Creating a MessageConsumer Consumer: Starting connection so MessageConsumer can receive messages
You can do this in up to three windows, specifying a different name for each queue.
In a separate window, use runSample.sh to run the Producer program:
$ ./runSample.sh org.apache.qpid.example.jmsexample.fanout.Producer Using QPID_HOME: /usr/share/java/ Using QPID_SAMPLE: /usr/share/doc/rhm-0.2 Producer: Creating a non-transacted, auto-acknowledged session Producer: Creating a Message Producer Producer: Creating a TestMessage to send to the destination Producer: Sending message: 1 Producer: Sending message: 2 Producer: Sending message: 3 Producer: Sending message: 4 Producer: Sending message: 5 Producer: Sending message: 6 Producer: Sending message: 7 Producer: Sending message: 8 Producer: Sending message: 9 Producer: Sending message: 10 Producer: Closing connection Producer: Closing JNDI context
Now go back to the window where the Listener program is running. You should see output like this:
Consumer: Received message: Message 1 Consumer: Received message: Message 2 Consumer: Received message: Message 3 Consumer: Received message: Message 4 Consumer: Received message: Message 5 Consumer: Received message: Message 6 Consumer: Received message: Message 7 Consumer: Received message: Message 8 Consumer: Received message: Message 9 Consumer: Received message: Message 10 Consumer: Received final message That's all, folks! Consumer: Closing connection Consumer: Closing JNDI context