rss
SOATUBE
Oracle
Custom Search SOABYTE here

Monday, November 8, 2010

Use logical names to reference resources (Destinations,ConnectionFactory) instead of directly referencing the JNDI locations

Yes, it is possible to use logical names to reference resouces. Using logical names helps in making the configuration resource provider-independent. The recommended approach is to use logical names for JMS destinations and connection factories. Here's how it is achieved;


Declare Logical Name:
Before the logical names can be used they must be declared. This can be achieved by adding the following in application-client.xml. In the below example the following 4 logical names have been created namely jms/InboundTopicCF, jms/InboundQueueCF, jms/MyInboundTopic, jms/MyInboundQueue.
<?xml version="1.0" encoding="UTF-8"?>
<application-client xmlns="http://java.sun.com/xml/ns/j2ee"
                    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
                                        http://java.sun.com/xml/ns/j2ee/application-client_1_4.xsd"
                    version="1.4">
  <resource-ref>
    <res-ref-name>jms/InboundTopicCF</res-ref-name>
    <res-type>javax.jms.XATopicConnectionFactory</res-type>
    <res-auth>Application</res-auth>
  </resource-ref>
  <resource-ref>
    <res-ref-name>jms/InboundQueueCF</res-ref-name>
    <res-type>javax.jms.XAQueueConnectionFactory</res-type>
    <res-auth>Application</res-auth>
  </resource-ref>
  <message-destination-ref>
    <message-destination-ref-name>jms/MyInboundTopic</message-destination-ref-name> 
    <message-destination-type>javax.jms.Topic</message-destination-type>
    <message-destination-usage>Consumes</message-destination-usage>
  </message-destination-ref>
  <message-destination-ref>
  <message-destination-ref>
    <message-destination-ref-name>jms/MyInboundQueue</message-destination-ref-name>
    <message-destination-type>javax.jms.Queue</message-destination-type>
    <message-destination-usage>Consumes</message-destination-usage>
  </message-destination-ref>
</application-client>

Map Logical name to explicit JNDI location
After the logical names are created, the logical names must be mapped to the JNDI locations of resources. This can be achieved by adding the following in orion-application-client.xml.
<?xml version="1.0" encoding="UTF-8"?>
<orion-application-client xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                          xsi:noNamespaceSchemaLocation="http://xmlns.oracle.com/oracleas/schema/orion-application-client-10_0.xsd"
                          schema-major-version="10"
                          schema-minor-version="0">
  <resource-ref-mapping
    location = "java:comp/resource/InboundRP/XATopicConnectionFactories/myTCF"
    name = "jms/InboundTopicCF"/>
  <resource-ref-mapping
    location = "java:comp/resource/InboundRP/XAQueueConnectionFactories/myQCF"
    name = "jms/InboundQueueCF"/>
  <message-destination-ref-mapping
    location = "java:comp/resource/InboundRP/Topics/JMS_MY_TOPIC"
    name = "jms/MyInboundTopic"/>
  <message-destination-ref-mapping
    location = "java:comp/resource/InboundRP/Queues/JMS_MY_QUEUE"
    name = "jms/MyInboundQueue"/>
</orion-application-client>
(Note: Copy both application-client.xml and orion-application-client.xml at $OH/bpel/system/classes/META-INF location.)

Reference logical names in SOA JMS adapter
Modify SOA JMS Adapter connector factory to reference the newly created logical names. This can be achieved by modifying ..../application-deployments/default/JmsAdapter/oc4j-ra.xml. 
 <connector-factory location="eis/Jms/InboundTopicCF" connector-name="JmsAdapter">
  <config-property name="connectionFactoryLocation" value="java:comp/env/jms/InboundTopicCF"/>
  <config-property name="factoryProperties" value="java.naming.factory.initial=com.evermind.server.ApplicationClientInitialContextFactory;java.naming.provider.url=opmn:ormi://myserver.mydomain:6003:oc4j_soa/default;java.naming.security.principal=oc4jadmin;java.naming.security.credentials=oc4jadmin"/>
  <config-property name="acknowledgeMode" value="AUTO_ACKNOWLEDGE"/>
  <config-property name="isTopic" value="true"/>
  <config-property name="isTransacted" value="false"/>
  <config-property name="username" value="jmsuser"/>
  <config-property name="password" value="jmsuser"/>
  <connection-pooling use="none">
  </connection-pooling>
  <security-config use="none">
  </security-config>
 </connector-factory> 
 <connector-factory location="eis/Jms/InboundQueueCF" connector-name="JmsAdapter">
  <config-property name="connectionFactoryLocation" value="java:comp/env/jms/InboundQueueCF"/>
  <config-property name="factoryProperties" value="java.naming.factory.initial=com.evermind.server.ApplicationClientInitialContextFactory;java.naming.provider.url=opmn:ormi://myserver.mydomain:6003:oc4j_soa/default;java.naming.security.principal=oc4jadmin;java.naming.security.credentials=oc4jadmin"/>
  <config-property name="acknowledgeMode" value="AUTO_ACKNOWLEDGE"/>
  <config-property name="isTopic" value="false"/>
  <config-property name="isTransacted" value="false"/>
  <config-property name="username" value="jmsuser"/>
  <config-property name="password" value="jmsuser"/>
  <connection-pooling use="none">
  </connection-pooling>
  <security-config use="none">
  </security-config>
 </connector-factory>  

For more information related to the use of logical names with OEMS (AQJMS) provider refer to the below link
http://download.oracle.com/docs/cd/B31017_01/web.1013/b28958/jms.htm#CHDEIDDI&nbsp
 

0 comments:

Post a Comment

 
Blogger Profile