Configuring JMS Application Modules for Deployment 5-9
5.5 Generating Unique Runtime JNDI Names for JMS Resources
JMS resources, such as connection factories and destinations, are configured with a JNDI name. The runtime implementations of these resources are then bound into JNDI
using the given names. In some cases, it is impossible or inconvenient to provide a static JNDI name for these resources.
An example of such a situation is when JMS resources are defined in a JMS module within an application library. In this case, the library can be referenced from multiple
applications, each of which receive a copy of the application library and the JMS module it contains when they are deployed. If you were to use static JNDI names for
the JMS resources in this case, all applications that refer to the library would attempt to bind the same set of JNDI resources at the same static JNDI name.
Therefore, the first application to deploy would successfully bind the JMS resources into JNDI, but subsequent application deployments would fail with exceptions
indicating that the JNDI names are already bound.
To avoid this problem, WebLogic Server provides a facility to dynamically generate a JNDI name for the following types of JMS resources:
■
Connection factory
■
Destination queue and topic
■
Weighted distributed destination deprecated
■
Weighted distributed destination members
■
Uniform distributed destination The facility to generate unique names is based on placing a special character sequence
called {APPNAME} in the JNDI name of the above mentioned JMS resources. If you include {APPNAME} in the JNDI name element of a JMS resource either in the JMS
module descriptor, or the weblogic-ejb-jar.xml descriptor, the actual JNDI name used at runtime will have the {APPNAME} string replaced with the effective
application ID name and possibly version of the application hosting the JMS resource.
5.5.1 Unique Runtime JNDI Name for Local Applications
In the case of JMS modules in a local application, at runtime {APPNAME} becomes the nameID of the application. For example:
jndi-name{APPNAME}jmsMyConnectionFactoryjndi-name When deployed within an application called MyApp, it would result in a runtime JNDI
name of: MyAppjmsMyConnectionFactory
Note: The {APPNAME} facility does not imply that you can define
your own variables and substitute their values into the JNDI name at runtime. The string {APPNAME} is treated specially by the JMS
implementation, and no other strings of the form {some name} have any special meaning.
5-10 Configuring and Managing JMS for Oracle WebLogic Server
5.5.2 Unique Runtime JNDI Name for Application Libraries
In the case of JMS modules in an application library, at runtime {APPNAME} becomes the nameID of the application which refers to the library not the name of
the library. For example:
jndi-name{APPNAME}jmsMyConnectionFactoryjndi-name When deployed within an application library called MyAppLib, and referenced from
an application called MyApp, it would result in a runtime JNDI name of: MyAppjmsMyConnectionFactory
5.5.3 Unique Runtime JNDI Name for Standalone JMS Modules
In the case of JMS modules deployed as stand-alone modules, at runtime {APPNAME} becomes the nameID of the stand-alone module. For example:
jndi-name{APPNAME}jmsMyConnectionFactoryjndi-name When deployed within a stand-alone JMS module MyJMSModule, it would result in a
runtime JNDI name of: MyJMSModulejmsMyConnectionFactory
5.5.4 Where to Use the {APPNAME} String
The {APPNAME} string can be used anywhere you refer to the JNDI name of a JMS resource. For example, in the:
■
jndi-name or local-jndi-name element of connection-factory elements in the JMS module descriptor.
■
jndi-name or local-jndi-name element of queue or topic elements in the JMS module descriptor.
■
jndi-name element of distributed-queue or distributed-topic elements in the JMS module descriptor.
■
jndi-name element of uniform-distributed-queue or uniform-distributed-topic elements in the JMS module descriptor.
■
destination-jndi-name element of message-destination-descriptor elements in the weblogic-ejb-jar.xml descriptor.
■
jndi-name element of weblogic-enterprise-bean elements in the weblogic-ejb-jar.xml descriptor.
5.5.5 Example Use-Case