Oracle9iAS Containers for J2EE Services Guide Release 2 (9.0.3) Part Number A97690-01 |
|
This chapter describes the Java Message Service (JMS) furnished as part of Oracle9iAS Containers for J2EE (OC4J). This chapter discusses the following topics:
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.
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.
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:
class
attribute with the name of the resource-provider class.
name
attribute with a name by which to identify the resource provider. This name will be used in finding the resource provider in the application's JNDI as "java:comp/resource/name/"
.
description
tag with a description of the specific resource provider.
property
tags that the specific resource provider needs to be given as parameters.
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.
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:
ResourceName
name component.
Identify the JNDI name of the data source to use as the resource provider within the <resource-provider>
element.
application.xml
file.
orion-application.xml
file of the application.
The following is an example of how to configure the resource provider using XML syntax for Oracle JMS.
class
attribute--The oracle.jms.OjmsContext
class, which is configured in the class
attribute, implements the Oracle JMS resource provider.
property
attribute--Identify the data source that is to be used as this resource provider in the property
element. The topic or queue connects to this data source to access the tables and queues that facilitate the messaging.
<resource-provider class="oracle.jms.OjmsContext" name="cartojms1"> <description> OJMS/AQ </description> <property name="datasource" value="jdbc/CartEmulatedDS"></property> </resource-provider>+
For details on configuring data sources, see "Defining Data Sources".
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:
QueueReceiver
or TopicSubscriber
.
QueueReceiver
or TopicSubscriber
and its factory at deployment time.
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
This section discusses the following third-party resource providers:
Here are the operations that the resource provider interface supports:
java:comp/resource/
.
The context scanning resource provider class is a generic resource provider class that is shipped with OCJ for use with third-party message providers.
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/
.
<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>
$J2EE_HOME/lib
:
com.ibm.mq.jar com.ibm.mqbind.jar com.ibm.mqjms.jar mqji.properties
fscontext.jar
and providerutil.jar
to $J2EE_HOME/lib
.
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
.
<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>
Sonic_client.jar
and Sonic_XA.jar
, to $J2EE_HOME/lib
.
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
.
<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>
swiftmq.jar
to $J2EE_HOME/lib
.
|
Copyright © 1996, 2002 Oracle Corporation. All Rights Reserved. |
|