user manual
Chapter 20: Message-Driven Beans and JMS 215
Naming Support and Configuration
Naming Support and Configuration
Since MDBs have no interfaces, MDBs do not have JNDI names in the normal
sense like EJBHome objects do. Instead, they are associated with two objects
that must preexist in JNDI before the MDB is deployed. These are:
■
a connection factory to use for connecting to the JMS services provider and
■
a queue/topic on that provider to listen to for incoming messages
The JNDI names for these objects are specified in the MDB's ejb-borland.xml
deployment descriptor. The <connection-factory-name> captures the resource
connection factory used to connect to the JMS service provider. The
<message-driven-destination-name> element captures the actual topic/queue
on which the MDB is to listen. Once these elements are specified, the MDB
has all the information it needs to connect to the JMS service provider, receive
messages, and send replies.
Connecting to JMS Connection Factories from MDBs
MDBs provide a special case for connecting to JMS connection factories. In
ejb-jar.xml, attaching a JMS resource to an MDB requires the <message-
driven-destination> entry in the MDB's declaration. For example:
<message-driven>
<ejb-name>MyMDBTopic</ejb-name>
...
<message-driven-destination>
<destination-type>javax.jms.Topic</destination-type>
<subscription-durability>Durable</subscription-durability>
</message-driven-destination>
...
</message-driven>
Consult the J2EE 1.3 Specification for the proper uses of this element. Again,
the Borland-specific XML file binds the logical name with the JNDI name. It
uses two elements to accomplish this: <connection-factory-name> and <message-
driven-destination>.
First, let's examine the <connection-factory-name> element from the ejb-
borland.xml DTD:
<!ELEMENT connection-factory-name (#PCDATA)>
It's hardly a complicated element. Its value is the JNDI name of the JMS topic
or queue connection factory. That is, it is identical to the <jndi-name> element
found within the <resource-ref> declaration we just discussed. So, the ejb-
borland.xml declaration for an MDB looks like this:










