Adding message destinations

The J2EE 1.4 specification provides a means for J2EE components to refer to message destination objects by using "logical" names called message destination references. You can use the deployment descriptor editors to define message destination references.

About this task

Message destinations are elements that specify logical message destinations within an application. The message-destination element defines a message-destination-name, which is used for linking. Message destinations can be defined in any module in the J2EE application as the referencing component. A message destination link on a message destination reference or a message-driven bean points to the name of a message destination.

At deployment, the message destination references are bound to the administered message destinations in the target operational environment.

Restriction: Only the following minimum project levels can include message destinations:
  • J2EE 1.4 Application Clients
  • EJB 2.1 projects
  • 2.4 Web Applications

For each message destination that you define, a message-destination element is added to the deployment descriptor for that application component.

The following code shows an example message destination defined in a deployment descriptor:

<message-destination>
	<description></description>
	<message-destination-name>MyDest</message-destination-name>
</message-destination>

Procedure

  1. Open the deployment descriptor editor for the module project where you want to add a message destination. To do this, in the Enterprise Explorer of the Java™ EE perspective, double-click the deployment descriptor node for your project.
  2. In the Message Destinations section of the editor, click the Add button. This section is on different pages of the editor depending on the module type:
    • Application client projects: Overview page
    • Dynamic Web projects: Variables page
    • EJB projects: Assembly page
  3. In the Name field, specify a name for the message destination. The value entered in the Name field is used in the message-destination-name element in the deployment descriptor and is the value that could be used by a message destination reference or message-driven bean as its message-destination-link element. The message destination allows an EJB to send a message to a specific message-driven bean in the same application. The name is arbitrary, and both sender and receiver specify the same name as the value for their <message-destination-link> elements. Here is an example of code containing a sample <message-destination> value:
    <?xml version="1.0" encoding="UTF-8"?>
    <ejb-jar xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd"
    	version="3.0">
    	<display-name>TestEJB</display-name>
    	<enterprise-beans>
    		<message-driven>
    			<ejb-name>ConsumerBean</ejb-name>
    			<message-destination-link>ConsumerDestination</message-destination-link>
    		</message-driven>
    		<session>
    			<ejb-name>ProducerBean</ejb-name>
    			<message-destination-ref>
    				<message-destination-ref-name>beans.ProducerBean/destination</message-destination-ref-name>
    				<message-destination-link>ConsumerDestination</message-destination-link>
    			</message-destination-ref>
    		</session>
    	</enterprise-beans>
    	<assembly-descriptor>
    		<message-destination>
    			<description></description>
    			<message-destination-name>ConsumerDestination</message-destination-name>
    		</message-destination>
    	</assembly-descriptor>
    </ejb-jar>
     
  4. In the Description text area, enter a description for the message destination. Click Finish.
  5. Click Finish.

Results

The message destination is added to the deployment descriptor. Now, when you define message destination references, you can link to this message destination. In the Message Driven Destinations section of the editor, you can select the message destination and change the name and description. You can also remove the message destination.

Feedback