6.4.1. Running the Direct Examples

6.4.1. Running the Direct 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:

  1. 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.

  2. In the java directory, use runSample.sh to run the Consumer program:

    $  ./runSample.sh org.apache.qpid.example.jmsexample.direct.Consumer
    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
    
  3. In a separate window, use runSample.sh to run the Producer program:

    $  ./runSample.sh org.apache.qpid.example.jmsexample.direct.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
    
  4. Now go back to the window where the Consumer program is running. You should see the following output:

    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