deploytool Tips for Components That Send Messages

You set resource references and message destination references for any component that sends messages: a client, a session or entity bean, or even another message-driven bean. For examples, see Chapter 34. In this application, the client is the sending component. To view this example in deploytool, expand the SimpleMessageApp node, and then select SimpleMessageClient from the tree view.

Setting the Resource References

You use the Resource Ref's tabbed pane to specify the connection factory references for the component.

  1. In the tree view, select the component node.
  2. Select the Resource Ref's tab.
  3. Click Add.
  4. In the Coded Name field, enter the name that matches the parameter of the lookup method in the component code. For example, because the lookup parameter is java:comp/env/jms/MyConnectionFactory, the coded name should be jms/MyConnectionFactory.
  5. In the Type field, select the connection factory class that matches the destination type. The destination class in the code is javax.jms.ConnectionFactory, so select that class.
  6. In the Authentication field, in most cases you will select Container. You would select Application if your code explicitly logged on to the messaging service.
  7. In the Sharable field, make sure that the checkbox is selected. This choice allows the container to optimize connections.
  8. In the Sun-specific Settings area, enter the name of the connection factory (in this case, jms/ConnectionFactory) in the JNDI Name field. Enter guest in both the User Name and the Password fields.

Setting the Message Destination References

For any new application, you use the Msg Dest Ref's tab to specify the destination of messages. The Resource Env Ref's tab provides similar information, but it is available primarily for backward compatibility.

  1. Select the Msg Dest Ref's tab.
  2. Click Add.
  3. In the Coded Name field of the dialog box that appears, type a name that matches the parameter of the lookup call that locates the queue or topic. In this example, the lookup parameter is java:comp/env/jms/QueueName, so the coded name is jms/QueueName.
  4. In the Destination Type combo box, choose the class that matches the destination type (in this case, javax.jms.Queue).
  5. From the Usage combo box, choose either Produces or ConsumesProduces, depending on whether this component sends messages or both sends and receives messages. For this example, choose Produces.
  6. In the Destination Name field, type the name of the physical destination you created (in this case, PhysicalQueue).

Setting the Message Destinations

When you use the Msg Dest Ref's tab, you also use the Message Destinations tab of the component JAR file to link the destination to its JNDI name.

  1. Select the Message Destinations tab.
  2. Click Add.
  3. In the Destination Name field, type the name of the destination (in this case, PhysicalQueue) and press Return. The name also appears in the Display Name field. The names of the components that consume and produce messages for the destination appear in the Producers and Consumers areas.
  4. In the JNDI Name field, type the name of the JMS resource you created (in this case, jms/Queue).

Specifying the JNDI Names

The JNDI name for a message-driven bean is the name of the destination resource.

  1. In the tree view, select the application's node.
  2. Click Sun-specific Settings on the General screen.
  3. On the JNDI Names screen, enter the appropriate names. For example, the SimpleMessageApp discussed in this chapter uses the JNDI names shown in Table 28-1.

Table 28-1 JNDI Names for the SimpleMessageApp Application
Component or Reference Name