Message-Driven Beans

Two message-driven beans examples are provided with JOnAS. The first and simplest is located in $JONAS_ROOT/examples/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 of how to write and use message driven beans.

The second example is more complex and is located in $JONAS_ROOT/examples/src/mdb/sampleappli. The example contains two Message Driven beans one listening to a topic (StockHandlerBean) and 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 the message, the StockHandlerBean updates 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 and all examples is to start in the $JONAS_ROOT/examples/src directory and enter the following command line:

ant -find build.xml install

This command will compile all examples in the $JONAS_ROOT/examples/src directory.