Sun Java System Application Server |
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.
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:
install_dir
is the directory where Application Server
is installed.
app_dir
is the application base directory: install_dir/samples/ejb/mdb/apps/simple
.
mdb-simple.ear
.
Follow this general procedure:
build.xml
, is in the app_dir
directory, specifically, install_dir/samples/ejb/mdb/apps/simple
.
install_dir/samples/ejb/mdb/apps/simple/mdb-simple.ear
.
There are three ways to configure resources for this sample application:
Configuring JMS Resources
asant
. The build.xml
file includes a
predefined set of ant
targets for configuring resources.
install_dir/samples/ejb/mdb/apps/simple
asant deploy-jms-resource
Load this URL in your browser: http://hostname:admin-port
http://hostname:port/asadmin
.
jms/MyMDBQcf
javax.jms.QueueConnectionFactory
jms/MyQueue
javax.jms.Queue
asadmin
:
asadmin create-jms-resource --restype javax.jms.QueueConnectionFactory
--user username --password password jms/MyMDBQcf
asadmin create-jms-resource --restype javax.jms.Queue --user
amin-user --password admin-password
--property Name=MyQueue jms/MyQueue
To run the client application:
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
If you encounter problems, in addition to viewing the Application Server log files, look at the MQ broker log files, for example:
install_dir/domains/domain1/imq/instances/samplesbroker1/log/log.txt
install_dir/domains/domain1/imq/instances/samplesbroker2/log/log.txt
Copyright © 2005 Sun Microsystems, Inc. All rights reserved.