8 Understanding Resource Providers

The following topics describe how to configure and use resource providers that define the JNDI properties that allow the JMS resource adapter to connect to the WebLogic JMS provider:

Basic Resource Provider Configuration

The JMS resource adapter utilizes a configuration property named resourceProviderDefinitions in the ra.xml file to define resource providers, such as JNDI properties. The resourceProviderDefinitions property is used by the JMS resource adapter to access WebLogic JMS. You can configure multiple resource providers in an ra.xml file.

Note:

When specifying the resourceProviderDefinitions property, you may need to use the per cent character (%) as an escape character if your WebLogic Server JNDI URL includes one or more commas to delimit multiple properties.

For example, if the URL is represented as t3://host:port,host2:port2, then the JMS resource adapter will fail to parse the URL because a comma is inserted after host:port.

To resolve this issue, insert a per cent character (%) immediately prior to the comma. For example: t3://host:port%,host2,port

To configure a resource provider, complete the following steps in the ra.xml file:

    1. Specify the resourceProviderDefinitions property as the value of the <config-property-name> element. For example:

      <config-property-name>resourceProviderDefinitions</config-property-name>
      
    2. Specify java.lang.String as the value of the <config-property-type> element. For example:

      <config-property-type>java.lang.String</config-property-type>
      
    3. Define the specific JNDI properties for a resource provider by using the following name-value pair pattern:

      (RP_NAME: jndiEnv=property1=(value1,property2=value2,...))
      

      In this name-value pattern:

    • RP_NAME is a unique name for the JNDI properties of a resource provider and is used with the rpResourceLocation configuration property of the <connection-definition> and <adminobject> elements. For more information, see Sending Outbound JMS Messages.

      Note:

      Each defined resource provider name (RP_NAME) must be unique in the ra.xml file.

    • property1=value1,property2=value2,... is a comma-separated list of name-value pairs that define the JNDI properties for a resource provider.

See Example Resource Provider Configuration for an example configuration.

Advanced Method for Configuring Resource Providers

The JMS resource adapter supports the groupDefinitions property to provide an advanced method for configuring resource providers. Using this property enables you to create a compatible set of messaging objects while providing flexible address resolution of connection factories and administered objects. Using the groupDefinitions property has a dependency on the following components:

  • Group—A set of compatible messaging objects, such as connection factories and associated destination administered objects.

  • Macro—A Group component that is substituted for a rpResourceLocation configuration property in connection factories and administered objects.

To configure a groupDefinitions property in the ra.xml file, complete the following steps:

  1. Specify groupDefinitions as the value of the <config-property-name> element. For example:
    <config-property-name>groupDefinitions</config-property-name>
    
  2. Specify java.lang.String as value of the <config-property-type> element. For example:
    <config-property-type>java.lang.String</config-property-type>
    
  3. Define a Group configuration by using the following pattern:
    <config-property-value>
       GROUP_NAME: macro
    </config-property-value
    

    In the preceding pattern:

    • GROUP_NAME is a unique name that represents a Group configuration.

    • macro is a comma-separated list of name-value pairs that define a set of compatible messaging objects. The JMS resource adapter substitutes these pairs for rpResourceLocation configuration properties in connection factories and administered objects.

See Example Resource Provider Configuration for an example configuration.

Example Resource Provider Configuration

The following shows an example resource provider configuration. In this example:

  • Two resource providers are configured: rp1and rp2.

  • Two Group objects are configured: GroupA and GroupB.

. . .
     <config-property>
        <config-property-name>resourceProviderDefinitions</config-property-name>
        <config-property-type>java.lang.String</config-property-type>
// Example Configuration for two resource providers: rp1 and rp2
        <config-property-value>
           (rp1: jndiEnv=(java.naming.factory.initial=
                    weblogic.jms.WrappedInitialContextFactory,
                    java.naming.provider.url=t3://@@@HOST@@@:7002,
                    java.naming.security.principal=wxyzUser1,
                    java.naming.security.credentials=wxyzPass1))
            (rp2: jndiEnv=(java.naming.factory.initial=
                    weblogic.jms.WrappedInitialContextFactory,
                    java.naming.provider.url=t3://anotherhost:8002,
                    java.naming.security.principal=wxyzUser1,
                    java.naming.security.credentials=wxyzPass1))
        </config-property-value>
. . .
     </config-property>
        <config-property>
        <config-property-name>groupDefinitions</config-property-name>
        <config-property-type>java.lang.String</config-property-type>
        <config-property-value>
                (GroupA:  connectorName=rp1,
                            cf=myCF,
                            xacf=myXACF,
                            topic1=myT1,
                            topic2=myT2,
                            queue1=myQ1,
                            queue2=myQ12)
                (GroupB:  connectorName=rp2,
                            cf=example/cf,
                            xacf=example/xacf,
                            queue1=queue1,
                            queue2=queue2)
        </config-property-value>
     </config-property>
. . .