next up previous contents
Next: 4 Contacts Up: JOTM Examples guide Previous: 2 Basic Example   Contents

Subsections


3 JMS Example

JOTM can be used with any JMS (Java Message Service) provider to gain advantage of both message-oriented architecture and distributed transactions.
This example uses JORAM (http://www.objectweb.org/joram/) as its JMS provider.

All Ant commands are to be executed from the examples/jms/ directory of a JOTM distribution (examples won't work from JOTM source directory).


3.1 Scenario

The jms example shows how to use JOTM with a JMS provider (in our case, JORAM) to provide distributed transactional messages.

On one hand, SimpleSender sends 4 messages on a JMS queue:

On the other hand, SimpleReceiver receives 3 messages from the same JMS queue:

(SimpleReceiver does not receive the 3rd sent message because it has been rolled back.)


3.2 Setup and compilation

To compile the example, type

$ ant compile


3.3 Run the example

First, you've to set JOTM_HOME to the directory of your JOTM distribution (e.g., .../jotm/output/dist from CVS).
$ export JOTM_HOME=<JOTM_distribution_directory>
To run the example, type
$ rmiregistry &
$ $JOTM_HOME/bin/jotm.sh start -u UserTransaction -m
TransactionManager &
$ ant run.jms

Since the client application of the jms example is a simple RMI/JRMP client, you've to use default protocol configuration for JOTM (i.e RMI/JRMP) in ../../config/rmi.properties file.


3.4 Output

the output of the jms example should be somethnig like

$ ...
$
$ [java] [SimpleJmsXa] lookup the TransactionManager.
$ [java] [SimpleJmsXa] start the JMS server.
$ [java] [SimpleJmsXa] JMS server started.
$ [java] [SimpleJmsXa] create JMS objects, register them in JOTM and bind them.
$ [java] [SimpleJmsXa] JMS objects available.
$ [java] [SimpleJmsXa] start simple sender.
$ [java] [SimpleSender] send : non transactional message
$ [java] [SimpleSender] send : transactional message with commit
$ [java] [SimpleSender] send : transactional message with rollback
$ [java] [SimpleSender] send : LAST message
$ [java] [SimpleJmsXa] start simple receiver.
$ [java] [SimpleReceiver] received: non transactional message
$ [java] [SimpleReceiver] received: transactional message with commit
$ [java] [SimpleReceiver] received: LAST message
$ [java] [SimpleJmsXa] JMS server stopped
$
$ ...

If SimpleSender has effectively sent 4 messages and SimpleReceiver has effectively received only 3 messages, then the jms example is working!


next up previous contents
Next: 4 Contacts Up: JOTM Examples guide Previous: 2 Basic Example   Contents
Jeff Mesnil 2002-11-12