Sun Java System Application Server Enterprise Edition 8.1 2005Q2 Developer's Guide

- Previous: Restrictions and Optimizations
- Next: Handling Transactions with Enterprise Beans

## Sample Message-Driven Bean XML Files

This section includes the following sample files:

- Sample ejb-jar.xml File

- Sample sun-ejb-jar.xml File

For general information on the `sun-ejb-jar.xml` file, see The sun-ejb-jar.xml File.

### Sample ejb-jar.xml File

    <?xml version="1.0" encoding="UTF-8"?>
    <!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>MessageBean</ejb-name>
    		<ejb-class>samples.mdb.ejb.MessageBean</ejb-class>
    		<transaction-type>Container</transaction-type>
    		<message-driven-destination>
    			<destination-type>javax.jms.Queue</destination-type>
    		</message-driven-destination>
    		<resource-ref>
    			<res-ref-name>jms/QueueConnectionFactory</res-ref-name>
    			<res-type>javax.jms.QueueConnectionFactory</res-type>
    			<res-auth>Container</res-auth>
    		</resource-ref>
    	</message-driven>
    </enterprise-beans>
    	<assembly-descriptor>
    		<container-transaction>
    			<method>
    				<ejb-name>MessageBean</ejb-name>
    				<method-intf>Bean</method-intf>
    				<method-name>onMessage</method-name>
    				<method-params>
    					<method-param>javax.jms.Message</method-param>
    				</method-params>
    			</method>
    		<trans-attribute>NotSupported</trans-attribute>
    	</container-transaction>
    </assembly-descriptor
    </ejb-jar>

### Sample sun-ejb-jar.xml File

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE sun-ejb-jar PUBLIC '-//Sun Microsystems, Inc.//DTD Application
    Server 8.1 EJB 2.1//EN'
    'http://www.sun.com/software/appserver/dtds/sun-ejb-jar_2_1-1.dtd'>
    <sun-ejb-jar>
    <enterprise-beans>
    	<ejb>
    		<ejb-name>MessageBean</ejb-name>
    		<jndi-name>jms/sample/Queue</jndi-name>
    		<resource-ref>
    			<res-ref-name>jms/QueueConnectionFactory</res-ref-name>
    			<jndi-name>jms/sample/QueueConnectionFactory</jndi-name>
    			<default-resource-principal>
    				<name>guest</name>
    				<password>guest</password>
    			</default-resource-principal>
    		</resource-ref>
    		<mdb-connection-factory>
    			<jndi-name>jms/sample/QueueConnectionFactory</jndi-name>
    			<default-resource-principal>
    				<name>guest</name>
    				<password>guest</password>
    			</default-resource-principal>
    		</mdb-connection-factory>
    	</ejb>
    </enterprise-beans>
    </sun-ejb-jar>

- Previous: Restrictions and Optimizations
- Next: Handling Transactions with Enterprise Beans

- © 2010, Oracle Corporation and/or its affiliates