khai thác gỗ vẫn sẽ được kiểm soát phần nào bởi những hạn chế đặt trên các EJB, mà chúng tôi vạch ra trước đó trong chương. Bởi vì đậu trạng thái phiên có thể có Chương 16: Giới thiệu doanh nghiệp JavaBeans thụ động nhà nước Một trong những phổ biến hơn bạn có khả năng đi qua là phần mềm máy chủ | Chapter 22 JMS Step 6 Create a simple text message and send it out Message msg Simple text message Step 7 Send the message out msg Step 1. Before you can do anything else you need to establish a connection with the JMS provider. You do this with administered objects as described in the section Administered Objects. In this preliminary step you retrieve the connection factory that has been placed into the JNDI namespace. First create an initial context using default JNDI parameters from a file . Once you have created the initial context you can look up an object that is bound to the name ConnectionFactory . Finally cast the object to the appropriate type in this case QueueConnectionFactory. Step 2. Once you have retrieved the QueueConnectionFactory object from the JNDI namespace you can use it to create a connection to the JMS provider. Note that this connection factory is specific to the JMS provider. It knows how to establish a connection what protocols to use what steps are required and so on. But since it implements the ConnectionFactory interface all you have to do is call the appropriate routine in this case createQueueConnection. Step 3. The next step is to create a session from the connection. You do this with the createQueueSession method which takes two arguments. The first is a Boolean flag that indicates whether the session is to be transacted or not. See the later section Use transactions with JMS for more details. The second argument is the acknowledgement mode to be used for this session. Notice that there are predefined constants that you should use in specifying the mode. Step 4. In this step you retrieve another administered object - the queue. This example assumes you have previously placed a queue object into the JNDI name- space as described in the administered objects section. You can use the same context you created in Step 1. Look up the queue object that has been bound to the name .