-
1. Re: Testing a MDB
ftg314159 Mar 10, 2004 5:28 PM (in response to tonig)You probably noticed that there is nothing in the <message-driven> section of the ejb-jar that identifies the Queue being serviced by your MDB.
WARNING: The XML below is invalid; it has extra spaces in some labels, because otherwise this posting service swallows them
The way to do this is server-(i.e. JBoss-)specific. You need two things:
1) you need a file called jbossmq-something-service.xml containing something like:
< server>
< mbean code="org.jboss.mq.server.jmx.Queue" name="jboss.mq.destination:service=Queue,name=yourMDBname">
< depends optional-attribute-name="DestinationManager">
jboss.mq:service=DestinationManager
</ depends>
</ mbean>
</ server>
This goes into your "deploy" directory as a standalone, and basically tells JBoss that your MDB needs messaging services.
2) You need entries in a jboss.xml file (this goes in the META-INF directory of your EJB jar file, same place as ejb-jar.xml):
< jboss>
< secure>false</ secure>
<resource-managers>
<!--
For JMS, we need a resource manager for each Connection Factory
and each queue or topic.
The Connection Factories should point to java:/JmsXA.
-->
<resource-manager>
<res-name>QueueFactory</res-name>
<res-jndi-name>java:/JmsXA</res-jndi-name>
</resource-manager>
<resource-manager>
<res-name>yourMDBName</res-name>
<res-jndi-name>queue/yourQueueName</res-jndi-name>
</resource-manager>
</resource-managers>
</ jboss>
This tells JBoss to create a Queue named "yourQueueName" which it will show to the outside world with a JNDI name of queue/yourQueueName, and associate it with your MDB so that when message arrive it will call your bean's onMessage().
This should do it for an MDB referenced by a client, although you may have to play with whatever needs to precede queue/ in the JNDI name. It's a little more complicated if the client is a session EJB, but I'll leave that out for now.
You may have problems with this, because the only way I've done it is with a session EJB as the client, and I may have left something out when I pruned stuff out of my descriptors, but give it a try.
A good reference for this stuff is the JBoss companion workbook for the O'Reilly "Enterprise JavaBeans" book. I thikn this is part of the JBoss docs, or maybe you get it from the O'Reilly site. It has all of the JBoss-specific stuff you need to get the examples in the book to work, along with code.