Sun Java System Application Server 

Samples Index

The Message Driven Bean (MDB) Simple Sample Application

The Message Driven Bean (MDB) simple application provides an example of an MDB, which is an enterprise bean that allows Java 2 Enterprise Edition (J2EE) applications to process messages asynchronously. An MDB acts as a JMS message listener, which is similar to an event listener except that it receives messages instead of events. The messages may be sent by any J2EE component (an application client, another enterprise bean, or a web component), or by a JMS application or system that does not use J2EE technology.

Building, Deploying, and Running the Application

The general instructions for building, deploying, and running sample applications are provided in Building, Deploying, and Running Sample Applications. In reading this document, use the following application-specific variables for this application:

Follow this general procedure:

  1. Build the Application. The build file, build.xml, is in the app_dir directory, specifically, install_dir/samples/ejb/mdb/apps/simple.
  2. Configure JMS Resources
  3. Deploy the Application. The EAR file is install_dir/samples/ejb/mdb/apps/simple/mdb-simple.ear.
  4. Run the client, as described below.

Configuring JMS Resources

There are three ways to configure resources for this sample application:

Running the Client

To run the client application:

  1. Change to the directory where you deployed the sample.
  2. Run appclient as follows:
    cd install_dir/samples/ejb/mdb/apps/simple
    install_dir/bin/appclient
     -client mdb-simpleClient.jar -name SimpleMessageClient
     -textauth -xml domain_root_dir/config/sun-acc.xml

For example, to run the client using appclient, use this command:

appclient -client mdb-simpleClient.jar
 -name SimpleMessageClient
 -textauth -xml domain_root_dir/config/sun-acc.xml

The results will be something like this:

Sending message: This is message 1
Sending message: This is message 2
Sending message: This is message 3

 

The message bean receives the messages, which are then printed in the log file server.log:

MESSAGE BEAN: Message received: This is message 1
MESSAGE BEAN: Message received: This is message 2
MESSAGE BEAN: Message received: This is message 3

For example, to run client in the samples domain, enter this command:

appclient -client mdb-simpleClient.jar
-name SimpleMessageClient -textauth
-xml install_dir/domains/samples/config/sun-acc.xml

Troubleshooting

If you encounter problems, in addition to viewing the Application Server log files, look at the MQ broker log files, for example:


Copyright © 2005 Sun Microsystems, Inc. All rights reserved.