Two message-driven beans examples are provided with JOnAS. The first and simplest is located in
$JONAS_ROOT/examples/src/mdb/samplemdb
topic and an 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.
$JONAS_ROOT/examples/src/mdb/sampleappli
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 (Stock-
Bean), 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 StockHan-
dlerBean 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.
7.1. Building the Examples
The simplest way to compile this and all examples is to start in the
directory and enter the following command as user
ant -find build.xml install
This compiles all examples in the
7.2. Running the Examples
To run the
samplemdb
client. Finally, at the end of the execution you should stop the JOnAS server.
Note
$JONAS_ROOT/examples/src/mdb/samplemdb
example.
Here is how to proceed:
1. As
, start the Red Hat Application Server server with the following command:
root
/sbin/service jonas start
jonas admin -a samplemdb.jar
2. Start the Java Client:
jclient samplemdb.MdbClient
A successful run should output something similar to:
JMS client: tcf = TCF:localhost-16010
JMS client: tc = Cnx:#0.0.1030-21
MDBsample is OK
3. As
, stop the Red Hat Application Server server:
root
/sbin/service jonas stop
$JONAS_ROOT/examples/src
example, you will have to first start the JOnAS server and then run the Java
Message-Driven Beans
; it contains a Message Driven bean listening to a
has the second, more complex, example. The
$JONAS_ROOT/examples/src
:
jonas
directory.
is assumed to be the current folder in the following
Chapter 7.
Need help?
Do you have a question about the APPLICATION SERVER - JONAS and is the answer not in the manual?
Questions and answers