Skip Headers

Oracle9iAS Containers for J2EE Services Guide
Release 2 (9.0.3)

Part Number A97690-01
Go To Core Documentation
Core
Go To Platform Documentation
Platform
Go To Table Of Contents
Contents
Go To Index
Index

Go to previous page Go to next page

9
Java Message Service

This chapter describes the Java Message Service (JMS) furnished as part of Oracle9iAS Containers for J2EE (OC4J). This chapter discusses the following topics:

Overview

Java clients and Java middle-tier services must be capable of using enterprise messaging systems. JMS offers a common way for Java programs to access these systems. JMS is the standard messaging API for passing data asynchronously between application components, allowing business integration in heterogeneous and legacy environments. JMS provides two programming models:

JMS queues and topics are bound to the JNDI environment and made available to J2EE applications.

OC4J provides a ResourceProvider interface to transparently plug in third-party JMS implementations. The JMS resources are available under java:comp/resource through the resource provider interface delegation.

Resource Providers

The ResourceProvider interface enables you to plug in third-party message providers for JMS connections. For Oracle JMS, this allows EJBs, servlets, and OC4J clients to access many different queue implementations. With third-party message providers, only EJBS can access queue implementations. The resources are available under java:comp/resource/ as the default JMS resources.

Configuring a Custom Resource Provider

To add a custom <resource-provider>, add the following to your orion-application.xml file:

<resource-provider class="providerClassName" name="JNDI name">
     <description>
         description
     </description>
     <property name="name" value="value" />
</resource-provider>

In place of the user-replaceable constructs (those in italics) in the preceding code, do the following:

Using a Custom Resource Provider

Use the following lookup syntax to retrieve a resource provider's resources:

java:comp/resource/providerName/resourceName 

Where providerName is the name of the resource provider (as given in the attribute name described in the previous section) and resourceName is the name of a resource this resource provider furnishes.

Using Oracle JMS as a Resource Provider

The ResourceProvider interface allows you to plug in Oracle JMS, which enables J2EE code (EJBs, MDBs, JSPs, servlets, application clients, and so on) to access Oracle AQ.

To access Oracle JMS queues through JMS, you must do the following:

  1. Create an RDBMS user through which the JMS application will connect to the back-end database. The user must have the necessary privileges to perform Oracle JMS operations. Oracle JMS allows any database user to access queues in any schema, provided the user has the appropriate access privileges.

  2. Configure an OC4J resource provider with information about the back-end database. Create data sources or LDAP directory entries, if needed.

  3. Access the resource using Oracle JMS resource names, which include the ResourceName name component.


    Note:

    For the OC4J 9.0.3 implementation, MDB is integrated with Oracle JMS only through the resource provider interface.



    Note:

    Oracle JMS implements the JMS 1.0.2 specifications and complies with J2EE 1.3.


Configuring the Resource Provider

Identify the JNDI name of the data source to use as the resource provider within the <resource-provider> element.

The following is an example of how to configure the resource provider using XML syntax for Oracle JMS.

For details on configuring data sources, see "Defining Data Sources".

Using Message-Driven Beans

The OC4J message-driven beans (MDB: EJBs that process JMS messages asynchronously) are integrated only with Oracle JMS, through the resource provider interface. MDBs are not integrated with third-party message providers.

An MDB is a JMS message listener that can reliably consume messages from a queue or a subscription of a topic. The advantage of using an MDB instead of a JMS message listener is that you can use the asynchronous nature of a JMS listener with the following EJB container advantages:

Refer to the MDB chapter for details on deploying an MDB accessing Oracle JMS through the resource provider interface.

Download the MDB example from the OC4J sample code page 


Note:

Message-driven beans are supported only for Oracle JMS.


Using Third-Party Resource Providers


Note:

For 9.0.3, OC4J provides only a very limited set of operations, as described in this section, for calling out to third-party message providers through the resource provider interface for JMS applications.


This section discusses the following third-party resource providers:

Here are the operations that the resource provider interface supports:

The context scanning resource provider class is a generic resource provider class that is shipped with OCJ for use with third-party message providers.

Using MQSeries as a Resource Provider

The Resource Provider interface provides support for plugging in third-party JMS implementations. This example demonstrates how to make MQSeries the default Resource Provider for JMS connections. The MQSeries resources are available in OC4J under java:comp/resource/MQSeries/.

Configuring

  1. Install and configure MQSeries on your system, then verify the installation by running any examples or tools supplied by the vendor. (See the documentation supplied with your software for instructions.)

  2. Use the <resource-provider> tag in orion-application.xml to add MQSeries as a custom Resource Provider. Here is an example of using this tag for SonicMQ integration:

    <resource-provider
          class="com.evermind.server.deployment.ContextScanningResourceProvider"
          name="MQSeries">
      <description> MQSeries resource provider </description>
      <property 
          name="java.naming.factory.initial"
          value="com.sun.jndi.fscontext.RefFSContextFactory">
      </property>
      <property
          name="java.naming.provider.url"
          value="file:/var/mqm/JNDI-Directory">
      </property>
    </resource-provider>
    
    
  3. Add the following MQSeries JMS client jar files to $J2EE_HOME/lib:

    com.ibm.mq.jar
    com.ibm.mqbind.jar
    com.ibm.mqjms.jar
    mqji.properties
    
    
  4. Add the file system JNDI JAR files fscontext.jar and providerutil.jar to $J2EE_HOME/lib.

Using SonicMQ as a Resource Provider

SonicMQ is a messaging broker with a complete implementation of the JMS 1.0.2 specification. The resource provider interface furnishes support for plugging in third-party JMS implementations. This example describes how to make SonicMQ the default resource provider for JMS connections. The SonicMQ resources are available in OC4J under java:comp/resource/SonicMQ.


Note:

SonicMQ broker does not embed a JNDI service. Instead, it relies on an external directory server to register the administered objects. Administered objects, such as queues, are either created by an administrator--using SonicMQ Explorer or programmatically--using the Sonic Management API. Oracle registers the administered objects from SonicMQ Explorer using the file system JNDI.


  1. Install and configure SonicMQ on your system, then verify the installation by running any examples or tools supplied by the vendor. (See the documentation with your software for instructions.)

  2. Use the <resource-provider> tag in orion-application.xml to add SonicMQ as a custom resource provider. The following example demonstrates using SonicMQ as the message provider and the file system as the JNDI store:

    <resource-provider
      class="com.evermind.server.deloyment.ContextScanningResourceProvider"
      name="SonicJMS">
       <description>
          SonicJMS resource provider.
       </description>
       <property name="java.naming.factory.initial"
          value="com.sun.jndi.fscontext.RefFSContextFactory">
       <property name="java.naming.provider.url"
          value="file:/private/jndi-directory/">
    </resource-provider>
    
  3. Add the SonicMQ JMS client JAR files, Sonic_client.jar and Sonic_XA.jar, to $J2EE_HOME/lib.

Using SwiftMQ as a Resource Provider

SwiftMQ is a messaging broker with a complete implementation of the JMS 1.0.1 specification. The Resource Provider interface furnishes support for plugging in third-party JMS implementations. This example describes how to make SwiftMQ the default ResourceProvider for JMS connections. The SwiftMQ resources are available in OC4J under java:comp/resource/SwiftMQ.

  1. Install and configure SwiftMQ on your system, then verify the installation by running any examples or tools supplied by the vendor. (See the documentation provided with your software for instructions.)

  2. Use the <resource-provider> tag in orion-application.xml to add SwiftMQ as a custom resource provider, as shown in the following:

    <resource-provider
      class="com.evermind.server.deloyment.ContextScanningResourceProvider"
      name="SwiftMQ"> 
       <description> 
          SwiftMQ resource provider. 
       </description> 
       <property name="java.naming.factory.initial"
          value="com.swiftmq.jndi.InitialContextFactoryImpl"> 
       <property name="java.naming.provider.url" 
          value="smqp://localhost:4001"> 
    </resource-provider> 
    
  3. Add the SwiftMQ JMS JAR file swiftmq.jar to $J2EE_HOME/lib.


Go to previous page Go to next page
Oracle
Copyright © 1996, 2002 Oracle Corporation.

All Rights Reserved.
Go To Core Documentation
Core
Go To Platform Documentation
Platform
Go To Table Of Contents
Contents
Go To Index
Index