CLASSPATH
:TextMDB.java
. The source code for this example is located in JBoss Administration and Development, Chapter 4, Example 2.META-INF
in the output directory that now contains the org.jboss.chap4.ex2.TextMDB.class
.ejb-jar.xml
and jboss.xml
files in the META-INF directory. The code for these files is listed in Jboss Administration and Development, but the code below has slight modifications. <?xml version="1.0"?> <!-- The ejb-jar.xml descriptor --> <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd" > <ejb-jar> <enterprise-beans> <message-driven> <ejb-name>TextMDB</ejb-name> <ejb-class>org.jboss.chap4.ex2.TextMDB</ejb-class> <transaction-type>Container</transaction-type> <acknowledge-mode>AUTO_ACKNOWLEDGE</acknowledge-mode> <message-driven-destination> <destination-type>javax.jms.Queue</destination-type> </message-driven-destination> <resource-ref> <res-ref-name>jms/QCF</res-ref-name> <res-type>javax.jms.QueueConnectionFactory</res-type> <res-auth>Container</res-auth> </resource-ref> </message-driven> </enterprise-beans> </ejb-jar>
<?xml version="1.0"?> <!-- The jboss.xml descriptor --> <jboss> <enterprise-beans> <message-driven> <ejb-name>TextMDB</ejb-name> <destination-jndi-name>queue/B</destination-jndi-name> <resource-ref> <res-ref-name>jms/QCF</res-ref-name> <jndi-name>QueueConnectionFactory</jndi-name> </resource-ref> </message-driven> </enterprise-beans> </jboss>
In JBoss 3.0.4, the JNDI names QueueConnectionFactory
and TopicConnectionFactory
do not come pre-mapped to the internal JBoss connection factory called ConnectionFactory
. Therefore you must add this mapping in order to use the example MDB without modification. The mapping must be configured by adding the following lines in the file %JBOSS_DEPLOY%\jbossmq-service.xml
:
<!--========================================================== --> <!-- JBossMQ --> <!--========================================================== --> <mbean code="org.jboss.naming.NamingAlias" name="DefaultDomain:service=NamingAlias,fromName=QueueConnectionFactory"> <attribute name="ToName">ConnectionFactory</attribute> <attribute name="FromName">QueueConnectionFactory</attribute> </mbean> <mbean code="org.jboss.naming.NamingAlias" name="DefaultDomain:service=NamingAlias,fromName=TopicConnectionFactory"> <attribute name="ToName">ConnectionFactory</attribute> <attribute name="FromName">TopicConnectionFactory</attribute> </mbean>
%JBOSS_HOME%\bin
directory and issuing the following command:myejb.jar
to %JBOSS_DEPLOY%
.12:04:09,172 INFO [EjbModule] Creating 12:04:09,192 INFO [EjbModule] Deploying TextMDB 12:04:10,214 WARN [SecurityManager] No SecurityMetadadata was available for B adding default security conf 12:04:10,284 INFO [EjbModule] Created 12:04:10,294 INFO [EjbModule] Starting 12:04:10,304 INFO [EjbModule] Started 12:04:10,304 INFO [MainDeployer] deployment of package: file:/C:/jboss-3.0.0/server/default/deploy/myejb.jar
CLASSPATH
:org.jboss.chap4.ex2.SendRecvClient.java
. The source to this program is listed in Jboss Administration and Development.CLASSPATH
: %JBOSS_CLIENT%\jnp-client.jar %JBOSS_CLIENT%\jbossmq-client.jar %JBOSS_CLIENT%\jboss-common-client.jar %JBOSS_CLIENT%\jnet.jar %JBOSS_CLIENT%\log4j.jar %JBOSS_HOME%\clientThe
%JBOSS_HOME%\client
directory is included so that the filejndi.properties
in that directory can be found.In JBoss 3.0.4, a
java.naming.provider.url=localhostjndi.properties
does not come pre-configured for the client, therefore, you will have to create one. The easiest way is to first copyjndi.properties
from%JBOSS_CONF%
to%JBOSS_CLIENT%
. Then, un-comment the following line in the copied file:
java org.jboss.chap4.ex2.SendRecvClientYou should see output like the following in the client program window:
Begin sendRecvAsync sendRecvAsync, sent text=A text msg#0 sendRecvAsync, sent text=A text msg#1 sendRecvAsync, sent text=A text msg#2 sendRecvAsync, sent text=A text msg#3 ... End sendRecvAsync onMessage, recv text=A text msg#0processed by: 7438914 onMessage, recv text=A text msg#1processed by: 1639412 onMessage, recv text=A text msg#2processed by: 10668 onMessage, recv text=A text msg#3processed by: 1611150 ...You should also see output like the following in the JBoss server console:
[INFO,Default] TextMDB.ctor, this=7438914 [INFO,Default] TextMDB.setMessageDrivenContext, this=7438914 [INFO,Default] TextMDB.ejbCreate, this=7438914 [INFO,Default] TextMDB.ctor, this=1639412 [INFO,Default] TextMDB.setMessageDrivenContext, this=1639412 [INFO,Default] TextMDB.ejbCreate, this=1639412 [INFO,Default] TextMDB.onMessage, this=7438914 [INFO,Default] TextMDB.sendReply, this=7438914, dest=QUEUE.A [INFO,Default] TextMDB.ctor, this=10668 [INFO,Default] TextMDB.setMessageDrivenContext, this=10668 [INFO,Default] TextMDB.ejbCreate, this=10668 [INFO,Default] TextMDB.onMessage, this=1639412 [INFO,Default] TextMDB.sendReply, this=1639412, dest=QUEUE.A [INFO,Default] TextMDB.ctor, this=1611150 [INFO,Default] TextMDB.setMessageDrivenContext, this=1611150 [INFO,Default] TextMDB.ejbCreate, this=1611150 [INFO,Default] TextMDB.onMessage, this=10668 [INFO,Default] TextMDB.sendReply, this=10668, dest=QUEUE.A [INFO,Default] TextMDB.ctor, this=6808485 [INFO,Default] TextMDB.setMessageDrivenContext, this=6808485 [INFO,Default] TextMDB.ejbCreate, this=6808485 [INFO,Default] TextMDB.onMessage, this=1611150 [INFO,Default] TextMDB.sendReply, this=1611150, dest=QUEUE.A [INFO,Default] TextMDB.onMessage, this=6808485 [INFO,Default] TextMDB.sendReply, this=6808485, dest=QUEUE.A [INFO,Default] TextMDB.ctor, this=3277650 [INFO,Default] TextMDB.setMessageDrivenContext, this=3277650 [INFO,Default] TextMDB.ejbCreate, this=3277650 [INFO,Default] TextMDB.ctor, this=5224450 [INFO,Default] TextMDB.setMessageDrivenContext, this=5224450 [INFO,Default] TextMDB.ejbCreate, this=5224450 [INFO,Default] TextMDB.onMessage, this=3277650 [INFO,Default] TextMDB.sendReply, this=3277650, dest=QUEUE.A [INFO,Default] TextMDB.ctor, this=4280406 [INFO,Default] TextMDB.setMessageDrivenContext, this=4280406 [INFO,Default] TextMDB.ejbCreate, this=4280406 [INFO,Default] TextMDB.onMessage, this=5224450 [INFO,Default] TextMDB.sendReply, this=5224450, dest=QUEUE.A [INFO,Default] TextMDB.ctor, this=4977982 [INFO,Default] TextMDB.onMessage, this=4280406 [INFO,Default] TextMDB.sendReply, this=4280406, dest=QUEUE.A [INFO,Default] TextMDB.setMessageDrivenContext, this=4977982 [INFO,Default] TextMDB.ejbCreate, this=4977982 [INFO,Default] TextMDB.ctor, this=6805499 [INFO,Default] TextMDB.setMessageDrivenContext, this=6805499 [INFO,Default] TextMDB.ejbCreate, this=6805499 [INFO,Default] TextMDB.onMessage, this=4977982 [INFO,Default] TextMDB.sendReply, this=4977982, dest=QUEUE.A [INFO,Default] TextMDB.onMessage, this=6805499 [INFO,Default] TextMDB.sendReply, this=6805499, dest=QUEUE.A
TIBCO Enterprise Message Service™ Application Integration Guide Software Release 4.3, February 2006 Copyright © TIBCO Software Inc. All rights reserved www.tibco.com |