How To Use the JMS Router for OracleAS JMS and Oracle OJMS

Date: 02/03/06
Author:  John Leinaweaver


Introduction


  • Destinations of the same JMS provider.
  • Destinations of different JMS providers.

  • For persistent JMS message, the OracleAS JMS Router guarantees exactly-once message delivery.
  • For non-persistent JMS messages, the OracleAS JMS Router  guarantees at-most-once message delivery.
  • The OracleAS JMS Router guarantees the delivery of messages in the order they are received by the OracleAS JMS Router from the source destination.


how-to overview - 2 routing jobs will be configured

Prerequisites

What you need to know

  • You should be familiar with these technologies: JMS, JCA, and Oracle OJMS if trying the OracleAS JMS to Oracle OJMS demonstration.
  • Please look at the companion article for a detailed explanations of the JCA framework.
  • Link to other OC4J Howto's on OTN

Software Requirements

  • OracleAS 10.1.3 is installed, available from OTN
  • Sun's JDK 1.4.2_08 or above
  • Apache Ant 1.6.2 or above.
  • Oracle Database 10g (optional; only for the second part of this how-to)
  • Any HTML browser like Mozilla, Microsoft Internet Explorer, Netscape, etc.

Notations

  • %ORACLE_HOME% - The directory you installed OracleAS 10.1.3.
  • %JAVA_HOME% - The directory where your JDK is installed
  • % HOWTO_HOME% - The directory where this demo is unzipped.
  • %DB_HOST% - The hostname for Oracle OJMS.
  • %DB_SID% - Database Sid for Oracle OJMS.
  • %DB_PORT% - Database connection port for Oracle OJMS.

Building the Application

%HOWTO_HOME%/doc/javadoc

%HOWTO_HOME%/etc

OracleAS JMS Configuration



Oracle OJMS Configuration

The To use Oracle OJMS, this how-to requires additional configuration to use the Oracle OJMS provider.  These additional steps are provided in detail in the next section and entail:

  1. Setting up the OJMS schema in the database hosting Oracle OJMS.
  2. Deploying a JCA 1.5 compliant Oracle OJMS resource adapter.
  3. Defining the Oracle OJMS resource provider in the default application.xml file.
  4. Defining the data-source in the default data-sources.xml which will provide connection detail for the resource-provider.
  5. Updating the contents of the default oc4j-connectors.xml for the OJMS resource adapter.

The configuration descriptors for the Oracle OJMS resource adapter are located within the ./etc/rar directory.

 

Running the Application

Examining the Sample File Directories

The contents of the zip file include:

  • build - temporary directory created during the build.
  • doc - the How-to document and Javadocs
    • javadoc - the javadoc of the source file
    • How-to-JMSRouter
  • etc - all the necessary files to package the application.
    • application.xml - application descriptor.
    • orion-application.xml - OC4J specific application descriptor.
    • orion-web.xml - J2EE web deployment descriptor.
    • web.xml - OC4J specific deployment descriptor.
    • rar
      • META-INF
        • oc4j-ra.xml - OC4J specific resource adapter deployment descriptor.
        • ra.xml - resource adapter deployment descriptor.
  • lib - holds the application archives that could be deployed.
  • log - temporary directory for holding build/deploy logs.
  • sql - sql files
    • jmsrouteruser.sql - Oracle OJMS configuration script
  • src - contains all Java source code for the example
    • web
      • java
        • JMSRouterDemo.java - Servlet code which drives this demonstration.
  • ant-oracle.properties - property settings for building/deploying.
  • ant-oracle.xml - used by the Ant build file.
  • build.xml - Ant build file.

Configuring the Environment

ant-oracle.properties
  • oracle.home - the root directory of oracle installation.  Defaults to ORACLE_HOME env variable.
  • java.home -  the root directory of JDK installation.  Defaults to JAVA_HOME env variable.
  • oracleas.host - the hostname of the platform on which the OC4J instance is running.  Defaults to localhost.
  • oracleas.http.port - the port on which the OC4J HTTP listener is listening.  Defaults to 8888.
  • oracleas.admin.port  - the port on which the OC4J administration processor is listening.  Defaults to 23791.
  • oracleas.admin.user - the name of the OC4J administrator.  Defaults to "oc4jadmin".
  • oracleas.admin.password - the password for the OC4J administrator.  Defaults to "welcome".
  • oracleas.binding.module - the name of the HTTP web site to which the deployed application is bound.  Defaults to "http-web-site".

  • db.host - the hostname of the database where Oracle OJMS resides.  Defaults to DB_HOST env variable.
  • db.sid - the database SID for Oracle OJMS.  Defaults to DB_SID env variable.
  • db.port - the database port number for Oracle OJMS.  Defaults to DB_PORT env variable.
%ORACLE_HOME%/ant/bin

Starting the OC4J Instance

  • %ORACLE_HOME%/bin/oc4j start

Note that the oc4j command expects the JAVA_HOME environment variable to point to a full JDK installation.

Generating, Compiling and Deploying the Application

  • ant

You should now have the newly created jmsrouterdemo.ear in your %HOWTO_HOME%/lib directory.

This command would also attempt to deploy the application if the build is successful. It will first test whether OC4J is running.

Note that you can also deploy the application separately . Ensure the %ORACLE_HOME% environment variable is defined, and from the %HOWTO_HOME% directory, type the commands:

  • ant bind-web-app

Adding 'job1': OracleASjms to OracleASjms JMS Message Routing





http://<your_server_host>:8888/em

  • Select the Administration link.
  • Select JMS Providers under Services.
  • Select OracleAS JMSRouter under Related Links.
  • In the right frame, select the Operations tab, then addRouterJob

  • To create a routing job you will have to provide a JMS Router jobName. Enter job1 for value.
  • Click on pencil icon to define custom job properties.
  • Click 4 times on "Add Row".
  • Enter Key and Element values as per table below:

Custom job properties for job1.
Key Element
messageSource OracleASjms/Topics/jms/demoTopic
sourceConnectionFactory OracleASjms/MyCF
messageTarget OracleASjms/Queues/jms/demoQueue
targetConnectionFactory OracleASjms/MyCF

Then press the invoke operation button. When this completes, a new JMS Router job called "job1" is added that will route messages enqueued on OracleASjms' jms/demoTopic to OracleASjms' jms/demoQueue.
Running the JMS Router Application.

Adding 'job2': OracleASjms to Oracle OJMS JMS Message Routing

Define the Oracle OJMS Database Schema


  • sqlplus system/<password_for_system> as sysdba @jmsrouteruser.sql


Deploy the Resource Adapter


  • ant deploy-rar

Update the default OC4J configuration descriptors






  • %ORACLE_HOME%/bin/oc4j -shutdown -port <oracleas.admin.port> -password <your_password>

%OC4J_HOME%/j2ee/home/config

application.xml

   <resource-provider class="oracle.jms.OjmsContext" name="aqojmsRP">
     <description> OJMS/AQ </description>
     <property name="datasource" value="jdbc/aqojmsDS"></property>
   </resource-provider>

data-sources.xml%DB_HOST%%DB_PORT%%DB_SID%

   <managed-data-source login-timeout='-1'
             connection-pool-name='OJMS_thinPool'
             jndi-name='jdbc/aqojmsDS'
             name='ojmsthin' />
   <connection-pool name='OJMS_thinPool'>
      <proxy-interface sql-object='Connection'
                       interface='oracle.jdbc.internal.OracleConnection'/>
      <proxy-interface sql-object='Statement'
                       interface='oracle.jdbc.OracleStatement'/>
      <proxy-interface sql-object='CallableStatement'
                       interface='oracle.jdbc.OracleCallableStatement'/>
      <proxy-interface sql-object='PreparedStatement'
                       interface='oracle.jdbc.OraclePreparedStatement'/>
      <proxy-interface sql-object='ResultSet'
                       interface='oracle.jdbc.OracleResultSet'/>
      <connection-factory factory-class='oracle.jdbc.pool.OracleDataSource'
                       user='jmsrouteruser' password='jmsrouteruser'
                       url='jdbc:oracle:thin:@ %DB_HOST% : %DB_PORT%: %DB_SID%'>
      </connection-factory>
   </connection-pool>




     <adminobject-config location="aqojms/Queues">
         <adminobject-class>oracle.j2ee.ra.jms.generic.AdminObjectQueueImpl</adminobject-class>
         <config-property name="resourceProviderName" value="aqojmsRP"/>
     </adminobject-config>

     <adminobject-config location="aqojms/Topics">
         <adminobject-class>oracle.j2ee.ra.jms.generic.AdminObjectTopicImpl</adminobject-class>
         <config-property name="resourceProviderName" value="aqojmsRP"/>
     </adminobject-config>


  • %ORACLE_HOME%/bin/oc4j -start

Adding the JMS Message Router Job for OracleASjms to Oracle OJMS




http://<your_server_host>:8888/em .

  • Select the Administration link.
  • Select JMS Providers under Services.
  • Select OracleAS JMSRouter under Related Links.
  • In the right frame, select the Operations tab, then addRouterJob

  • provide a JMS Router jobName: job2
  • Click on pencil icon to define custom job properties.
  • Click 5 times on "Add Row".
  • Enter Key and Element values as per table below:

Key Element
messageSource OracleASjms/Topics/jms/demoTopic
sourceConnectionFactory OracleASjms/MyCF
messageTarget aqojms/Queues/Queues/ojmsQ1
targetConnectionFactory aqojms/AQCF
targetLogQueue aqojms/Queues/Queues/ojmsLogQ

invoke operation

Running the JMS Router Application


http://<your_server_host>:<your_server_port>/jmsrouterdemo


OracleAS JMS Message Router Demonstration

Sending messages to OracleASjms/jms/demoTopic (OracleASjms source for 'job1' and 'job2')
Sent Message: #1 :This is the message:
Sent Message: #2 :This is the message:
Sent Message: #3 :This is the message:
Sent Message: #4 :This is the message:
Sent Message: #5 :This is the message:

Receiving messages from OracleASjms/jms/demoQueue (OracleASjms target for 'job1')
Received Message #1 :This is the message:
Received Message #2 :This is the message:
Received Message #3 :This is the message:
Received Message #4 :This is the message:
Received Message #5 :This is the message:

Receiving messages from aqojms/Queues/Queues/ojmsQ1 (OJMS target for 'job2')
Received Message #1 :This is the message:
Received Message #2 :This is the message:
Received Message #3 :This is the message:
Received Message #4 :This is the message:
Received Message #5 :This is the message:

JMS Router Demonstration Finished.

Click here to RETURN to the JMS Router Page


 



Summary


  • How to configure OracleAS JMS Router jobs.
  • Using OracleAS JMS Router to move message between two different JMS Providers.









Left Curve
Popular Downloads
Right Curve
Untitled Document