The following sections provide information on how to lookup a destination:
The recommended way to lookup a destination or member of a distributed destination is to use JNDI. You can look up a destination by establishing a JNDI context (context) and executing one of the following commands, for PTP or Pub/Sub messaging, respectively:
Queue queue = (Queue) context.lookup(
Dest_name
);
Topic topic = (Topic) context.lookup(
Dest_name
);
The Dest_name argument specifies the destination's JNDI name defined during configuration. See Step 1: Look Up a Connection Factory in JNDI.
A less common method to lookup a destination or member of a distributed destination that does not use JNDI is to use one of the following QueueSession
or TopicSession
methods to reference a queue or topic, respectively:
Note:
ThecreateQueue()
and createTopic()
methods do not create destinations dynamically; they create only references to destinations that already exist. For information about creating destinations dynamically, see Chapter 6, "Using JMS Module Helper to Manage Applications."The value of queueName
and/or topicName
string is defined by:
"Using the Create Destination Identifier" when configuring a destination, see "JMS Queue: Configuration: General" and "JMS Topic: Configuration: General." For more information about these methods, see the javax.jms.QueueSession
, at http://java.sun.com/javaee/5/docs/api/javax/jms/QueueSession.html
, and javax.jms.TopicSession
Javadoc, at http://java.sun.com/javaee/5/docs/api/javax/jms/TopicSession.html
.
A string is defined by JMS_Server_Name/JMS_Module_Name!Destination_Name
(for example, myjmsserver/myModule-jms!mydestination
). When referencing a destination in an interop module, the string is defined by JMS_Server_Name/interop-jms!Destination_Name
(for example, myjmsserver/interop-jms!mydestination
).
Note:
To reference destination in releases prior to WebLogic 9.0, use a string defined byJMS_Server_Name!Destination_Name
(for example, myjmsserver!mydestination
).Once the destination has been defined, you can use the following Queue or Topic method to access the queue or topic name, respectively:
public String getQueueName( ) throws JMSException public String getTopicName( ) throws JMSException
To ensure that the queue and topic names are returned in printable format, use the toString()
method.
The Create Destination Identifier (CDI) is a reference name for a destination or a member of a distributed destination that provides a way to lookup a destination without JNDI using the standard JMS javax.jms.Session
createQueue
or
createTopic
API.
This name must be unique within the scope of the JMS server to which this destination is targeted. However, it does not need to be unique within the scope of the entire JMS module. For example, two queues can have the same CDI name as long as those queues are targeted to different JMS servers.
Note:
Since this name must be unique within the scope of a JMS server, verify whether other JMS modules may contain destination names that conflict with this name. It is the responsibility of the deployer to resolve the destination names targeted to JMS servers.The following sections provide examples on how to reference a destination or a member of a distributed destination:
The following section provides examples how to reference destinations:
This section provides an example of how to reference a destination using createQueue
or createTopic
with and without using CDI:
When CDI is not configured, a string defined by:
JMS_Server_Name/JMS_Module_Name!Destination_Name
When CDI is configured, a string defined by:
JMS_Server_Name/CDI_Name
Note:
When using server affinity, (replacingJMS_Server_Name
with ".
"), the search is restricted to the JMS connection host rather than the entire cluster.The following section provides examples how to reference destinations using JNDI:
When a JNDI name is configured, a string defined by:
Dest_JNDI_Name
When a local JNDI name is configured:
Dest_Local_JNDI_Name
Note:
The local JNDI name only works when the JNDI context host is on the same server as the destination. The JNDI context host is not necessarily the same as the connection host.The following section provides examples how to reference Uniform Distributed Destinations (UDDs):
This section provides an example of how to reference a UDD member or logical UDD using createQueue or createTopic with and without using CDI:
For an individual member when CDI is not configured, a string defined by:
jms-server-name)/module-name!jms-server-name@udd-name
For an individual member when CDI is configured, a string defined by:
jms-server-name)/cdi-name
Note:
In the CDI case when jms-server-name is replaced with ".", the API returns the first locally available/started member of the UDQ.The following section provides examples how to reference an individual member using JNDI
When a JNDI name is configured, a string defined by:
dest-jndi-name
When a local JNDI name is configured, a string defined by:
dest-local-jndi-name
Note:
The local JNDI name only works when the JNDI context host is on the same server as the destination. The JNDI context host is not necessarily the same as the connection host.When referencing a logical UDD, regardless of whether CDI is configured, a string defined by: module-name!udd-name