Message-Driven Beans

Two message-driven beans examples are provided with JOnAS. The first and simplest one is located in $JONAS_ROOT/example/src/mdb/samplemdb. It contains a Message Driven bean listening to a topic and a MdbClient which is a pure JMS Client that sends 10 messages on the corresponding topic. This is a very good example for understanding how to write and use message driven beans.

The second example is more complex and located in $JONAS_ROOT/example/src/mdb/sampleappli. It contains two Message Driven beans one listening to a topic (StockHandlerBean) the other listening to a queue (OrderBean), an Entity bean with container managed persistence (StockBean) and a Stateless Session bean for creating the table used in the database. SampleAppliClient sends several messages on the topic, at receipt of message the StockHandlerBean update the database via the StockBean and sends a message to the Queue inside a global transaction, all the EJBs are involved in transactions that may commit or rollback.

Building the examples

The simplest way to compile this example is to go under the example directory and to use the compile.sh shell script on Unix, or the compile.bat script on Windows.

If the GNU make is installed on your machine, you can build this sb example by using the Makefile file you find in this directory. To do so just type make.

Ant users can build all examples in one shot by going in $JONAS_ROOT/example and using ant compile.