Search This Blog

Friday, February 13, 2009

How to view AQ Queues via OC4J with the hermes tool

For the OC4J memory based JMS queues you can use the link below.

Hermes Configuration for OC4J memory based JMS

This article explains how  to view AQ based queues with hermes.

Set up your queues and AQ resource adapter etc using the following article.

http://rreddy.blogspot.com/2009/02/how-to-use-simple-mdb-with-oracle.html

From an OC4J install copy all these files to a temp directory

adminclient.jar
aqapi13.jar
bcel.jar
connector.jar
dms.jar
javax77.jar
jazncore.jar
jms.jar
jndi.jar
jta.jar
oc4j-internal.jar
oc4jclient.jar
ojdbc14.jar
optic.jar
pcl.jar

From the Hermes Tool create a classpath using the following ,

<classpathGroup id="ORACLE-SOA">
       <library jar="D:\TEMP\aqapi13.jar" noFactories="true"/>
       <library jar="D:\TEMP\jms.jar" noFactories="true"/>
       <library jar="D:\TEMP\optic.jar" noFactories="true"/>
       <library jar="D:\TEMP\jta.jar" noFactories="true"/>
       <library jar="D:\TEMP\oc4jclient.jar" noFactories="true"/>
       <library jar="D:\TEMP\ojdbc14.jar" noFactories="true"/>
       <library jar="D:\TEMP\bcel.jar" noFactories="true"/>
       <library jar="D:\TEMP\connector.jar" noFactories="true"/>
       <library jar="D:\TEMP\adminclient.jar" noFactories="true"/>
       <library jar="D:\TEMP\oc4j-internal.jar" noFactories="true"/>
       <library jar="D:\TEMP\dms.jar" noFactories="true"/>
       <library jar="D:\TEMP\jazncore.jar" noFactories="true"/>
       <library jar="D:\TEMP\pcl.jar" noFactories="true"/>
   </classpathGroup>

Create a session using the following entries

<factory classpathId="ORACLE-SOA">
        <provider className="hermes.JNDIQueueConnectionFactory">
            <properties>
                <property name="binding" value="java:comp/resource/TEST_AQ/QueueConnectionFactories/QueueCF"/>
                <property name="initialContextFactory" value="oracle.j2ee.rmi.RMIInitialContextFactory"/>
                <property name="providerURL" value="ormi://localhost:23791"/>
                <property name="securityCredentials" value="welcome1"/>
                <property name="securityPrincipal" value="oc4jadmin"/>
            </properties>
        </provider>
        <connection clientID="" connectionPerThread="false">
            <session audit="false" id="OEMS" reconnects="0" transacted="true" useConsumerForQueueBrowse="false"/>
        </connection>
        <destination domain="1" name="java:comp/resource/TEST_AQ/Queues/MYQUEUE"/>
        <extension className="hermes.ext.DefaultHermesAdminFactory">
            <properties/>
        </extension>
    </factory>

The important entries are

binding ==>> java:comp/resource/TEST_AQ/QueueConnectionFactories/QueueCF

This can be found from the file oc4j-ra.xml file \

<connector-factory location="TEST_AQ/QueueCF" connector-name="TEST_AQ">
        <config-property name="jndiLocation" value="QueueConnectionFactories/QCF"/>

For the MDB we use the ConnectionFactory as TEST_AQ/QueueCF but for the hemes tool we need to use this as QueueConnectionFactories/QCF.

destination domain==> java:comp/resource/TEST_AQ/Queues/MYQUEUE                              For the MDB we use this as TEST_AQ/MyQueue/Queues/MYQUEUE but for the hermes tool we need use TEST_AQ/Queues/MYQUEUE.

After this send a message to the AQ using the script                               

DECLARE
enqueue_options dbms_aq.enqueue_options_t;
message_properties dbms_aq.message_properties_t;
message_handle RAW(16);
Message SYS.AQ$_JMS_TEXT_MESSAGE;
BEGIN
Message := Sys.Aq$_Jms_Text_Message.Construct;
Message.Set_Text(to_char(sysdate, 'DD/MM/YYYY HH24:MI:SS'));
dbms_aq.enqueue(queue_name => 'MYQUEUE',
enqueue_options => enqueue_options,
message_properties => message_properties,
payload => message,
msgid => message_handle);
COMMIT;
END;

1 comment:

augustin mateica said...

Hi Ravi,
I didn't succeded to connect with Hermes to my OJMS config.
Coud you take a look and tell me what is wrong
Here is my JMS Adaptor config oc4j-ra.xml:
&lgoc4j-connector-factories xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.oracle.com/technology/oracleas/schema/oc4j-connector-factories-10_0.xsd" schema-major-version="10" schema-minor-version="0" &gt
&lgconnector-factory location="LAS_Q_JMS/QueueCF" connector-name="LAS_RA"&gt
&lgconfig-property name="jndiLocation" value="QueueConnectionFactories/QCF"/&gt
&lgconnection-pooling use="private"&gt
&lgproperty name="waitTimeout" value="300" /&gt
&lgproperty name="scheme" value="fixed_wait" /&gt
&lgproperty name="maxConnections" value="50" /&gt
&lgproperty name="minConnections" value="0" /&gt
&lg/connection-pooling&gt
&lgsecurity-config use="none"&gt
&lg/security-config&gt
&lgconnectionfactory-interface&gtjavax.jms.QueueConnectionFactory&lg/connectionfactory-interface&gt
&lg/connector-factory&gt
&lg/oc4j-connector-factories&gt

Here is my resource provider:

&lgresource-provider name="LAS_Q_JMS" class="oracle.jms.OjmsContext"&gt
&lgdescription&gt&lg/description&gt
&lgproperty name="datasource" value="jdbc/xxevwkf_lasjms_pool" /&gt
&lg/resource-provider&gt