Skip Headers

Oracle® Containers for J2EE Enterprise JavaBeans Developer's Guide 10g Release 3 (10.1.3) B14428-01 |
| Home | Solution Area | Contents | Index

Previous | Next |

# Configuring an Environment Reference to a JMS Destination or Connection Resource Manager Connection Factory

You can access a JMS destination (queue or topic) and JMS connection resource manager connection factory by creating an environment reference to them.

Note: In EJB 3.0, an environment reference to a resource manager connection factory is not needed. You can access a resource manager connection factory directly using annotations and resource injection (see "Looking Up an EJB 3.0 Resource Manager Connection Factory").

For information on looking up a resource manager connection factory, see:

- "Looking Up an EJB 3.0 Resource Manager Connection Factory"

- "Looking Up an EJB 2.1 Resource Manager Connection Factory"

To define a reference to a JMS destination and JMS connection resource manager connection factory:

1. Configure your JMS service provider.

   For more information, see:

   - "Configuring an OracleAS JMS Message Service Provider"

   - "Configuring an OJMS Message Service Provider"

   - "Configuring a Message Service Provider Using J2CA"

2. Define the JNDI name for the JMS destination and connection factory.

   For more information, see:

   - "OracleAS JMS Destination and Connection Factory Names"

   - "OJMS Destination and Connection Factory Names"

   - "J2CA Message Service Provider Connection Factory Names"

3. Define a logical name for the JMS destination and JMS connection factory.

   How you define the logical names is the same regardless of what type of JMS provider you use.

   1. Define a `<resource-env-ref>` element in the appropriate client deployment descriptor (see "Where Do You Configure an EJB Environment Reference?") and configure the following sub-elements:

      - `<resource-env-ref-name>`: a logical name for the JMS destination resource manager connection factory.

      - `<resource-env-ref-type>`: The destination class type; either `javax.jms.Queue` or `javax.jms.Topic`.

      Example 19-7 shows a `<resource-env-ref>` element for a JMS topic resource manager connection factory.

      Example 19-7 <resource-env-ref> for a JMS Topic Destination

          <resource-env-ref>
            <resource-env-ref-name>rpTestTopic</resource-env-ref-name>
            <resource-env-ref-type>javax.jms.Topic</resource-env-ref-type>
          </resource-env-ref>

   2. Define a `<resource-ref>` element in the same client deployment descriptor and configure the following sub-elements:

      - <res-ref-name>: a logical name for the JMS connection resource manager connection factory.

      - <res-type>: the connection factory class type; either `javax.jms.QueueConnectionFactory` or `javax.jms.TopicConnectionFactory`.

      - <res-auth>: the authentication responsibility; either `Container` or `Bean`.

      - <res-sharing-scope>: the sharing scope; either `Shareable` or `Unshareable`.

      Example 19-8 shows a `<resource-ref>` element for a JMS topic connection resource manager connection factory.

      Example 19-8 <resource-ref> for a JMS Topic Connection Factory

          <resource-ref>
            <res-ref-name>myTCF</res-ref-name>
            <res-type>javax.jms.TopicConnectionFactory</res-type>
            <res-auth>Container</res-auth>
            <res-sharing-scope>Shareable</res-sharing-scope>
          </resource-ref>

4. Map the logical names to the actual JNDI names.

   1. Define a `<resource-env-ref-mapping>` element in the corresponding OC4J-specific deployment descriptor (see "Where Do You Configure an EJB Environment Reference?") and configure its `name` attribute to the JMS destination logical name (defined in the `<resource-env-ref>`) and its `location` attribute to the JNDI name defined when you configured your JMS provider (see step 2).

      Example 19-9 shows a `<resource-env-ref-mapping>` element for OracleAS JMS.

      Example 19-9 OracleAS JMS <resource-env-ref-mapping>

          <resource-env-ref-mapping
              name="rpTestTopic"
              location="jms/Topic/rpTestTopic">
          </resource-env-ref-mapping>

   2. Define a `<resource-ref-mapping>` element in the same OC4J-specific deployment descriptor (see "Where Do You Configure an EJB Environment Reference?") and configure its `name` attribute to the JMS connection factory logical name (defined in the `<resource-ref>`) and its `location` attribute to the JNDI name defined when you configured your JMS provider (see step 2).

      Example 19-10 shows a `<resource-ref-mapping>` element for OracleAS JMS.

      Example 19-10 OracleAS JMS <resource-ref-mapping>

          <resource-ref-mapping
              name="myTCF"
              location="jms/Topic/myTCF">
          </resource-ref-mapping>