deploytool Tips for Message-Driven Beans

Chapter 24 covers the basic steps for building and packaging enterprise beans. This section describes the tasks in deploytool that are necessary for message-driven beans. To view this example in deploytool, expand the SimpleMessageApp node in the tree view, and then expand the MDBJAR node and select SimpleMessageBean.

Specifying the Bean's Type

You specify the type when you create the bean using the New Enterprise Bean wizard.

  1. To start the wizard, select FileRight ArrowNewRight ArrowEnterprise Bean.
  2. 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.

Setting the Message-Driven Bean's Characteristics

You can specify these settings in two places:

These settings are as follows:

  1. For the Messaging Service, accept the default, JMS.
  2. For the Destination Type, choose either javax.jms.Queue or javax.jms.Topic. A queue uses the point-to-point messaging domain and can have at most one consumer. A topic uses the publish/subscribe messaging domain; it can have zero, one, or many consumers. For this example, you would select javax.jms.Queue.
  3. For the Target Message Destination, type the name of the physical destination that you created administratively. For an example, see the section Creating the Administered Objects. The destination is either a queue or a topic object; it represents the source of incoming messages and the target of outgoing messages. For this example, you would type PhysicalQueue.
  4. If your bean will be a durable subscriber to a topic, select the Durable Subscription checkbox and enter a subscription name. If the bean uses a message selector, enter the value in the Message Selector text area. For an example that uses these features, see A J2EE Application That Uses the JMS API with a Session Bean. You normally leave the Acknowledgement Mode set to Auto-Acknowledge.
  5. For information on durable subscriptions, see Creating Durable Subscriptions. For information on message selectors, see Message Selectors. For information on message acknowledgment, see Controlling Message Acknowledgment.

  6. In the Connection Factory JNDI Name (Sun-specific) field, type the JNDI name of the connection factory the bean will use. For this example, you would type jms/ConnectionFactory.

Use the tabbed panes as follows:

  1. In the Transactions tab of the bean:
    1. Select the Container-Managed radio button.
    2. Verify that the onMessage method has the Required attribute.
  2. In the Message Destinations tab of the bean JAR file:
    1. Click Add.
    2. Type the physical destination name (for this example, PhysicalQueue) in the Destination Name field, and press Enter.
    3. Type the JNDI name of the destination resource (for this example, jms/Queue) in the JNDI Name field.