Chapter 5. Running the Examples

In the directoryexamples, you will find 2 sets of examples:

The examples will be expanded on before JBoss Messaging 2.0 GA release

It is highly recommended that you familiarise yourself with the examples.

Make sure you start JBoss Messaging before running the examples!

5.1. The JMS examples

The following JMS examples are provided. To run these you will first need to start the server as shown in the installation chapter.

For each example, you can always override the default ports it will try to connect to by editing jndi.properties in the config directory

To run a specific example open up a shell or command prompt and navigate into the examples/jms directory and run the command ant followed by the example name, as follows

         ant queueExample
      

The output should be similar to the following

         Buildfile: build.xml

         init:
         [mkdir] Created dir: /home/andy/projects/jBossMessaging/docs/examples/jms/build

         compile:
         [javac] Compiling 5 source files to /home/andy/projects/jBossMessaging/docs/
         examples/jms/build

         queueExample:
         [java] 10:59:02,124 INFO @main [QueueExample] sending message to queue
         [java] 10:59:02,187 INFO @main [QueueExample] message received from queue
         [java] 10:59:02,187 INFO @main [QueueExample] message = This is a text message!

         BUILD SUCCESSFUL
         Total time: 3 seconds
      

The following examples are available

  • queueExample

    This example shows a simple send and receive to a remote queue using a JMS client

  • topicExample

    This example shows a simple send and receive to a remote topic using a JMS client

  • durSubExample

    This example shows the use of a durable subscriber.

  • perfSender

    This example will run a basic performance test. It sends messages to a destination according to the specified parameters. This needs to be used in conjunction with the perfListener example. The number of messages, delivery mode etc can be configured as follows:

    			    ant -Dmessage.count=20000 -Ddelivery.mode=PERSISTENT perfSender
                   

    The following parameters can be configured for the sender

    • message.count

      The number of messages to send.

    • delivery.mode

      The delivery mode to use, PERSISTENT or NON_PERSISTENT.

    • message.warmup.count

      How many messages to warm up for. Because of the JIT compiler maximum throughput will take a little while to kick in.

    • message.size

      The size of message to send, in bytes

    • sess.trans

      Whether or not the session is transacted.

    • sess.trans.size

      If the session is transacted the batch size to commit.

    • queue.lookup

      The name of the queue to use.

    • cf.lookup

      The name of the connection factory to use.

  • perfListener

    This example will run a basic performance test. It will consume messages from a destination according to the parameters specified. Before running start the example and wait for it to start, you will see READY!!! when the listener has started. The number of messages, delivery mode etc can be configured as follows:

                      ant -Dmessage.count=20000 -Ddelivery.mode=PERSISTENT perfSender
                   

    If running the sender and listener seperately make sure to run the listener with the parameter drain.queue set to false

    The following parameters can be configured:

    • message.count

      The number of messages to consume.

    • message.warmup.count

      How many messages to warm up for. Because of the JIT compiler maximum throughput will take a little while to kick in.

    • sess.trans

      Whether or not the session is transacted.

    • sess.trans.size

      If the session is transacted the batch size to commit.

    • sess.ackmode

      The acknowledge mode to use, DUPS_OK or AUTO_ACK. Ignored if the session is transacted

    • drain.queue

      Whether or not the listener will empty the queue before starting.

    • queue.lookup

      The name of the queue to use.

    • cf.lookup

      The name of the connection factory to use.

    There are also some ant targets for running the perf sender and listener in different modes:

                      perfNonTransactionalSender
                      perfTransactionalSender
                      perfAutoAckListener
                      perfDupsOKListener
                      perfDupsOKListener
                   

5.2. The Messaging examples

The messaging examples demonstrate the use of the messaging core API and also how to create and run an embedded instance of JBM. The following examples are available:

to run a specific example open up a shell or command prompt and navigate into the examples/messaging directory and run the command ant followed by the example name, as follows

         ant simpleClient
      
  • SimpleClient

    This example shows a simple send and receive to a remote queue using a core messaging client. The server will need to be running for this example.

  • SSLClient

    This example shows a simple send and receive to a remote queue using SS. The server will need to be running and configured to use SSL for this example. Refer to the configuration chapter for details on how to do this.

  • simpleExample

    This example shows how to create an embedded JBM server using the core API. The server must not have been started before running this example.