📄 mdb6.html
字号:
<?xml version="1.0" encoding="ISO-8859-1"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> <meta http-equiv="Content-Style-Type" content="text/css" /> <title>deploytool Tips for Message-Driven Beans</title> <link rel="StyleSheet" href="document.css" type="text/css" media="all" /> <link rel="StyleSheet" href="catalog.css" type="text/css" media="all" /> <link rel="Table of Contents" href="J2EETutorialTOC.html" /> <link rel="Previous" href="MDB5.html" /> <link rel="Next" href="MDB7.html" /> <link rel="Index" href="J2EETutorialIX.html" /> </head> <body> <table width="550" summary="layout" id="SummaryNotReq1"> <tr> <td align="left" valign="center"> <font size="-1"> <a href="http://java.sun.com/j2ee/1.4/download.html#tutorial" target="_blank">Download</a> <br> <a href="http://java.sun.com/j2ee/1.4/docs/tutorial/information/faq.html" target="_blank">FAQ</a> <br> <a href="http://java.sun.com/j2ee/1.4/docs/tutorial/information/history.html" target="_blank">History</a> </td> <td align="center" valign="center"><a accesskey="p" href="MDB5.html"><img id="LongDescNotReq1" src="images/PrevArrow.gif" width="26" height="26" border="0" alt="Prev" /></a><a accesskey="c" href="J2EETutorialFront.html"><img id="LongDescNotReq1" src="images/UpArrow.gif" width="26" height="26" border="0" alt="Home" /></a><a accesskey="n" href="MDB7.html"><img id="LongDescNotReq3" src="images/NextArrow.gif" width="26" height="26" border="0" alt="Next" /></a><a accesskey="i" href="J2EETutorialIX.html"></a> </td> <td align="right" valign="center"> <font size="-1"> <a href="http://java.sun.com/j2ee/1.4/docs/api/index.html" target="_blank">API</a> <br> <a href="http://java.sun.com/j2ee/1.4/docs/tutorial/information/search.html" target="_blank">Search</a> <br> <a href="http://java.sun.com/j2ee/1.4/docs/tutorial/information/sendusmail.html" target="_blank">Feedback</a></font> </font> </td> </tr> </table> <img src="images/blueline.gif" width="550" height="8" ALIGN="BOTTOM" NATURALSIZEFLAG="3" ALT="Divider"> <blockquote><a name="wp80310"> </a><h2 class="pHeading1">deploytool Tips for Message-Driven Beans</h2><a name="wp79802"> </a><p class="pBody">Chapter <a href="EJB.html#wp80468">19</a> covered the basic steps for building and packaging enterprise beans. This section describes the tasks in <code class="cCode">deploytool</code> that are necessary for message-driven beans. To view this example in <code class="cCode">deploytool</code>, expand the <code class="cCode">SimpleMessageApp</code> node in the tree view, then expand the <code class="cCode">MDBJAR</code> node and select <code class="cCode">SimpleMessageBean</code>.</p><a name="wp79803"> </a><h3 class="pHeading2">Specifying the Bean's Type</h3><a name="wp79804"> </a><p class="pBody">You specify the type when you create the bean with the New Enterprise Bean wizard.</p><div class="pSmartList1"><ol type="1" class="pSmartList1"><a name="wp79805"> </a><div class="pSmartList1"><li>To start the wizard, select File<span style="font-family: Symbol"><img src="images/arrwrite.gif" border="0" alt="Right Arrow"></span>New<span style="font-family: Symbol"><img src="images/arrwrite.gif" border="0" alt="Right Arrow"></span>Enterprise Bean.</li></div><a name="wp79806"> </a><div class="pSmartList1"><li>In the General dialog box of the wizard, choose the enterprise bean class of the bean, and accept the bean class name (the default) as the display name. The Enterprise Bean Type appears as Message-Driven by default.</li></div></ol></div><a name="wp79808"> </a><h3 class="pHeading2">Setting the Message-Driven Bean's Characteristics</h3><a name="wp79809"> </a><p class="pBody">You may specify these settings in two places:</p><div class="pSmartList1"><ul class="pSmartList1"><a name="wp79810"> </a><div class="pSmartList1"><li>The Message-Driven Bean Settings dialog box of the New Enterprise Bean wizard</li></div><a name="wp79814"> </a><div class="pSmartList1"><li>The Message-Driven tab of the bean</li></div></ul></div><a name="wp79815"> </a><p class="pBody">These settings are as follows:</p><div class="pSmartList1"><ol type="1" class="pSmartList1"><a name="wp79816"> </a><div class="pSmartList1"><li>For the Messaging Service, accept the default, JMS.</li></div><a name="wp81250"> </a><div class="pSmartList1"><li>For the Destination Type, select either <code class="cCode">javax.jms.Queue</code> or <code class="cCode">javax.jms.Topic</code>. A queue uses the point-to-point messaging domain and may have at most one consumer. A topic uses the publish/subscribe messaging domain; it may have zero, one, or many consumers. For this example, you would select <code class="cCode">javax.jms.Queue</code>.</li></div><a name="wp81270"> </a><div class="pSmartList1"><li>For the Target Destination Name, type the name of the physical destination that you created administratively. For an example, see the section <a href="MDB5.html#wp79772">Creating the Administered Objects</a>. The destination is either a <code class="cCode">queue</code> or a <code class="cCode">topic</code> object; it represents the source of incoming messages and the target of outgoing messages. For this example, you would type <code class="cCode">PhysicalQueue</code>.</li></div><a name="wp81290"> </a><div class="pSmartList1"><li>If your bean will be a durable subscriber to a topic, select the Durable Subscription checkbox and enter a subscription name. If it uses a message selector, enter the value in the Message Selector text area. For an example that uses these features, see <a href="JMSJ2EEex2.html#wp95588">A J2EE Application that Uses the JMS API with a Session Bean</a>. You normally leave the Acknowledgement Mode set to Auto-Acknowledge.</li></div><a name="wp81677"> </a><p class="pBodyRelative">For information on durable subscriptions, see <a href="JMS6.html#wp81941">Creating Durable Subscriptions</a>. For information on message selectors, see <a href="JMS4.html#wp79281">Message Selectors</a>. For information on message acknowledgment, see <a href="JMS6.html#wp81785">Controlling Message Acknowledgment</a>.</p><a name="wp81639"> </a><div class="pSmartList1"><li>In the Connection Factory JNDI Name (Sun-specific Setting) field, type the JNDI name of the connection factory the bean will use. For this example, you would type <code class="cCode">jms/QueueConnectionFactory</code>.</li></div></ol></div><a name="wp81296"> </a><p class="pBody">Use the tabbed panes as follows:</p><div class="pSmartList1"><ol type="1" class="pSmartList1"><a name="wp81297"> </a><div class="pSmartList1"><li>Transactions tab of the bean: </li></div><div class="pSmartList2"><ol type="a" class="pSmartList2"><a name="wp81523"> </a><div class="pSmartList2"><li>Select the Container-Managed radio button. </li></div><a name="wp81524"> </a><div class="pSmartList2"><li>Verify that the <code class="cCode">onMessage</code> method has the Required attribute.</li></div></ol></div><a name="wp81303"> </a><div class="pSmartList1"><li>Message Destinations tab of the bean JAR file:</li></div><div class="pSmartList2"><ol type="a" class="pSmartList2"><a name="wp81316"> </a><div class="pSmartList2"><li>Click Add.</li></div><a name="wp81317"> </a><div class="pSmartList2"><li>Type the physical destination name (for this example, <code class="cCode">PhysicalQueue</code>) in the Destination Name field and press Enter. </li></div><a name="wp81323"> </a><div class="pSmartList2"><li>Type the JNDI name of the destination resource (for this example, <code class="cCode">jms/Queue</code>) in the JNDI Name field.</li></div></ol></div></ol></div> </blockquote> <img src="images/blueline.gif" width="550" height="8" ALIGN="BOTTOM" NATURALSIZEFLAG="3" ALT="Divider"> <table width="550" summary="layout" id="SummaryNotReq1"> <tr> <td align="left" valign="center"> <font size="-1"> <a href="http://java.sun.com/j2ee/1.4/download.html#tutorial" target="_blank">Download</a> <br> <a href="http://java.sun.com/j2ee/1.4/docs/tutorial/information/faq.html" target="_blank">FAQ</a> <br> <a href="http://java.sun.com/j2ee/1.4/docs/tutorial/information/history.html" target="_blank">History</a> </td> <td align="center" valign="center"><a accesskey="p" href="MDB5.html"><img id="LongDescNotReq1" src="images/PrevArrow.gif" width="26" height="26" border="0" alt="Prev" /></a><a accesskey="c" href="J2EETutorialFront.html"><img id="LongDescNotReq1" src="images/UpArrow.gif" width="26" height="26" border="0" alt="Home" /></a><a accesskey="n" href="MDB7.html"><img id="LongDescNotReq3" src="images/NextArrow.gif" width="26" height="26" border="0" alt="Next" /></a><a accesskey="i" href="J2EETutorialIX.html"></a> </td> <td align="right" valign="center"> <font size="-1"> <a href="http://java.sun.com/j2ee/1.4/docs/api/index.html" target="_blank">API</a> <br> <a href="http://java.sun.com/j2ee/1.4/docs/tutorial/information/search.html" target="_blank">Search</a> <br> <a href="http://java.sun.com/j2ee/1.4/docs/tutorial/information/sendusmail.html" target="_blank">Feedback</a></font> </font> </td> </tr> </table> <img src="images/blueline.gif" width="550" height="8" ALIGN="BOTTOM" NATURALSIZEFLAG="3" ALT="Divider"><p><font size="-1">All of the material in <em>The J2EE(TM) 1.4 Tutorial</em> is <a href="J2EETutorialFront2.html">copyright</a>-protected and may not be published in other workswithout express written permission from Sun Microsystems.</font> </body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -